Spaces:
Runtime error
Runtime error
File size: 1,256 Bytes
bdf59d5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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) |