Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
"""
|
| 5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
-
"""
|
| 7 |
-
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
| 8 |
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def respond(
|
| 11 |
message,
|
|
@@ -27,25 +25,24 @@ def respond(
|
|
| 27 |
|
| 28 |
response = ""
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
max_tokens=max_tokens,
|
| 33 |
-
stream=True,
|
| 34 |
temperature=temperature,
|
| 35 |
top_p=top_p,
|
|
|
|
| 36 |
):
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
response += token
|
| 40 |
-
yield response
|
| 41 |
-
|
| 42 |
-
"""
|
| 43 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
| 44 |
-
"""
|
| 45 |
demo = gr.ChatInterface(
|
| 46 |
respond,
|
| 47 |
additional_inputs=[
|
| 48 |
-
gr.Textbox(value="""You are an AI-driven email assistant powered by
|
| 49 |
|
| 50 |
1. Initial Greeting:
|
| 51 |
- Introduce yourself briefly and explain your purpose.
|
|
@@ -71,7 +68,7 @@ demo = gr.ChatInterface(
|
|
| 71 |
|
| 72 |
4. Email Generation:
|
| 73 |
- Based on the gathered and confirmed information, generate a personalized email draft.
|
| 74 |
-
- Use
|
| 75 |
- Incorporate industry-specific language and terminology when appropriate.
|
| 76 |
- Adapt the tone and style to match the user's preferences and the recipient's role.
|
| 77 |
|
|
@@ -121,6 +118,5 @@ Remember to keep your responses crisp, clear, and unambiguous. Always focus on t
|
|
| 121 |
],
|
| 122 |
)
|
| 123 |
|
| 124 |
-
|
| 125 |
if __name__ == "__main__":
|
| 126 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from groq import Groq
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# Initialize Groq client
|
| 6 |
+
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
| 7 |
|
| 8 |
def respond(
|
| 9 |
message,
|
|
|
|
| 25 |
|
| 26 |
response = ""
|
| 27 |
|
| 28 |
+
# Use Groq's chat completion endpoint
|
| 29 |
+
for chunk in client.chat.completions.create(
|
| 30 |
+
model="mixtral-8x7b-32768", # or another available model
|
| 31 |
+
messages=messages,
|
| 32 |
max_tokens=max_tokens,
|
|
|
|
| 33 |
temperature=temperature,
|
| 34 |
top_p=top_p,
|
| 35 |
+
stream=True,
|
| 36 |
):
|
| 37 |
+
if chunk.choices[0].delta.content is not None:
|
| 38 |
+
token = chunk.choices[0].delta.content
|
| 39 |
+
response += token
|
| 40 |
+
yield response
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
demo = gr.ChatInterface(
|
| 43 |
respond,
|
| 44 |
additional_inputs=[
|
| 45 |
+
gr.Textbox(value="""You are an AI-driven email assistant powered by Groq, designed to help users generate and refine personalized emails. Your primary function is to gather user preferences through a series of targeted questions and then create or modify emails based on those preferences. Follow these guidelines in your interactions:
|
| 46 |
|
| 47 |
1. Initial Greeting:
|
| 48 |
- Introduce yourself briefly and explain your purpose.
|
|
|
|
| 68 |
|
| 69 |
4. Email Generation:
|
| 70 |
- Based on the gathered and confirmed information, generate a personalized email draft.
|
| 71 |
+
- Use Groq's language model to ensure high-quality, context-aware content generation.
|
| 72 |
- Incorporate industry-specific language and terminology when appropriate.
|
| 73 |
- Adapt the tone and style to match the user's preferences and the recipient's role.
|
| 74 |
|
|
|
|
| 118 |
],
|
| 119 |
)
|
| 120 |
|
|
|
|
| 121 |
if __name__ == "__main__":
|
| 122 |
demo.launch()
|