Spaces:
Runtime error
Runtime error
| import openai | |
| import gradio as gr | |
| openai.api_key ='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' | |
| prompt="The following is the prompt from teacher to a student to clarify doubts working in canvas infrastructure" | |
| def openai_chat(prompt): | |
| completions = openai.Completion.create( | |
| engine="text-davinci-003", | |
| prompt=prompt+"The following is the assistant for David tais work who is an instructor", | |
| max_tokens=1024, | |
| n=1, | |
| temperature=0.5, | |
| frequency_penalty=0, | |
| presence_penalty=0.6, | |
| stop=[" Human:", " AI:"] | |
| ) | |
| message = completions.choices[0].text | |
| return message.strip() | |
| def chatbot_his(input, history=[]): | |
| output = openai_chat(input) | |
| history.append((input, output)) | |
| return history, history | |
| gr.Interface(fn = chatbot_his, | |
| inputs = ["text",'state'], | |
| outputs = ["chatbot",'state']).launch(share=True) |