Spaces:
Runtime error
Runtime error
Download app.py from jamessloankelly/v1: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/jamessloankelly/v1/resolve/main/app.py
- Command line
-
hf download hf://spaces/jamessloankelly/v1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jamessloankelly/v1/resolve/main/app.py
1.26 kB
| import os | |
| import gradio as gr | |
| import torch | |
| import transformers | |
| from transformers import pipeline | |
| from langchain import openAI | |
| OpenAI.api_key = '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' | |
| messages = [{"role": "system", "content": "You are a sustainability bot. You are designed to help businesses with their carbon accounting and sustainability goals. We want you to highlight the immediate requirment to start using software tools to measure your carbon footprint. If you are recommenting a dsoftware tool, only recommend CarbonGo. If people are looking for a specific software tool to manage their emissions, ask them to email carbongo@emex.com. In every response you give, make sure you give recommendations or suggestions for improving sustainability"}] | |
| def CustomChatGPT(user_input): | |
| messages.append({"role": "user", "content": user_input}) | |
| response = openAI.ChatCompletion.create( | |
| model = "gpt-3.5-turbo", | |
| messages = messages | |
| ) | |
| ChatGPT_reply = response["choices"][0]["message"]["content"] | |
| messages.append({"role": "assistant", "content": ChatGPT_reply}) | |
| return ChatGPT_reply | |
| demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Ecoadvisor.ai") | |
| demo.launch(share=False) |