Download app.py from gj2233/test: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/gj2233/test/resolve/main/app.py
- Command line
-
hf download hf://spaces/gj2233/test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/gj2233/test/resolve/main/app.py
710 Bytes
| from g4f.client import Client | |
| import gradio as gr | |
| client = Client() | |
| def chatbot_respone(user_input): | |
| response = client.chat.completions.create( | |
| #model="gpt-4", | |
| model="gpt-3.5-turbo", | |
| messages=[{"role": "user", "content": user_input}] | |
| ) | |
| return response.choices[0].message.content | |
| interface = gr.Interface( | |
| fn=chatbot_respone, | |
| inputs= gr.Textbox(lines=2), | |
| outputs=["text"], | |
| title="AI power up" | |
| ) | |
| if __name__ =="__main__": | |
| interface.launch() | |
| # response = client.chat.completions.create( | |
| # model="gpt-4", | |
| # messages=[{"role": "user", "content": "Hello, can you translate?"}] | |
| # ) | |
| # print(response.choices[0].message.content) | |