| import gradio as gr | |
| import os | |
| from openai import OpenAI | |
| import os | |
| def echo(message, history): | |
| client = OpenAI( | |
| base_url="https://router.huggingface.co/v1", | |
| api_key=os.getenv('api'), | |
| ) | |
| completion = client.chat.completions.create( | |
| model="meta-llama/Llama-3.1-8B-Instruct:cerebras", | |
| messages=[ | |
| { | |
| "role": "user", | |
| "content": message | |
| } | |
| ], | |
| ) | |
| print(completion.choices[0].message) | |
| return str(completion.choices[0].message) | |
| demo = gr.ChatInterface(fn=echo, examples=["hello", "hola", "merhaba"], title="PGC Bot") | |
| demo.launch() |