| |
| """6.3 hugging face - gradio.ipynb |
| Automatically generated by Colab. |
| Original file is located at |
| https://colab.research.google.com/drive/1JpRdo-xi3cVH-bQtQp_mWpctxk0krUQR |
| """ |
|
|
| |
| import os |
| |
| |
|
|
| from groq import Groq |
| client = Groq() |
|
|
| import gradio as gr |
| from groq import Groq |
|
|
| |
| def groq(text): |
| client = Groq() |
| completion = client.chat.completions.create( |
| model="llama-3.1-8b-instant", |
| messages=[ |
| { |
| "role": "user", |
| "content": text |
| } |
| ] |
| ) |
| return(completion.choices[0].message.content) |
|
|
| |
| demo = gr.Interface( |
| fn=groq, |
| inputs=gr.Textbox(label="Enter text", lines=12), |
| outputs=gr.Textbox(label="query", lines=12) |
| ) |
|
|
| |
| demo.launch(debug=True) |