Spaces:
Runtime error
Runtime error
Download app.py from Meghanjali/chatbot: direct link, hf CLI and curl.
- Browser
- Download file 916 Bytes
-
https://huggingface.co/spaces/Meghanjali/chatbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/Meghanjali/chatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Meghanjali/chatbot/resolve/main/app.py
916 Bytes
| 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) |