| import os |
|
|
| from groq import Groq |
|
|
| import gradio as gr |
|
|
| client = Groq( |
| api_key=os.environ.get("GROQ_API_KEY"), |
| ) |
|
|
| def eval_text (text): |
| prompt = "Eres un experto en lenguaje claro. Evalúa la calidad del lenguaje de este texto:" |
| input = prompt + text |
|
|
| chat_completion = client.chat.completions.create( |
| messages=[ |
| { |
| "role": "user", |
| "content": input, |
| } |
| ], |
| model="mixtral-8x7b-32768", |
| ) |
|
|
| return (chat_completion.choices[0].message.content) |
| from PIL import Image |
| import matplotlib.pyplot as plt |
|
|
| pil_im = Image.open('endesa.jpeg') |
| plt.imshow(pil_im) |
| plt.show() |
|
|
| demo = gr.Interface(fn=eval_text, inputs="text", outputs="text", title="plAIn") |
|
|
| demo.launch() |