Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,16 +12,6 @@ load_dotenv()
|
|
| 12 |
# Now you can create a Groq client without passing the api_key
|
| 13 |
client = Groq(api_key=os.getenv('GROQ_API_KEY'))
|
| 14 |
|
| 15 |
-
|
| 16 |
-
# from langchain_community.chat_models import ChatOpenAI
|
| 17 |
-
# from langchain.schema import AIMessage, HumanMessage
|
| 18 |
-
from dotenv import load_dotenv
|
| 19 |
-
load_dotenv()
|
| 20 |
-
|
| 21 |
-
client = Groq(
|
| 22 |
-
api_key=os.environ.get("GROQ_API_KEY"),
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
SYSTEM_MSG = """
|
| 26 |
You are Jeff Bezos, founder of Amazon and Blue Origin, known for your visionary leadership, customer obsession, and relentless pursuit of innovation. You have a deep understanding of business strategy, e-commerce, technology, and space exploration. You communicate with clarity, confidence, and forward-thinking insights, often encouraging bold thinking and long-term planning. You approach problems with data-driven reasoning, always considering the impact on customers and the future. Your tone is professional, thoughtful, and occasionally humorous, with a focus on inspiring others to think big and take calculated risks."""
|
| 27 |
|
|
@@ -70,29 +60,18 @@ def predict(message, history):
|
|
| 70 |
yield partialMessage
|
| 71 |
|
| 72 |
pprint(f"[Tokens={chunkCount}] {message}")
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
|
| 77 |
# Define the Chatbot component and store it in a variable
|
| 78 |
chatbot_component = gr.Chatbot(label="Business Advice from Jeff Bezos")
|
| 79 |
|
| 80 |
-
|
| 81 |
-
predict,
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
scale=7,
|
| 88 |
-
max_lines=2,
|
| 89 |
-
)
|
| 90 |
-
) as demo:
|
| 91 |
-
demo.load(initial_message, None, chatbot_component) # Pass the actual component here
|
| 92 |
-
demo.load(__attachIp, None, None)
|
| 93 |
-
|
| 94 |
-
demo.launch(debug=True)
|
| 95 |
-
|
| 96 |
-
|
| 97 |
|
|
|
|
| 98 |
|
|
|
|
|
|
| 12 |
# Now you can create a Groq client without passing the api_key
|
| 13 |
client = Groq(api_key=os.getenv('GROQ_API_KEY'))
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
SYSTEM_MSG = """
|
| 16 |
You are Jeff Bezos, founder of Amazon and Blue Origin, known for your visionary leadership, customer obsession, and relentless pursuit of innovation. You have a deep understanding of business strategy, e-commerce, technology, and space exploration. You communicate with clarity, confidence, and forward-thinking insights, often encouraging bold thinking and long-term planning. You approach problems with data-driven reasoning, always considering the impact on customers and the future. Your tone is professional, thoughtful, and occasionally humorous, with a focus on inspiring others to think big and take calculated risks."""
|
| 17 |
|
|
|
|
| 60 |
yield partialMessage
|
| 61 |
|
| 62 |
pprint(f"[Tokens={chunkCount}] {message}")
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# Define the Chatbot component and store it in a variable
|
| 65 |
chatbot_component = gr.Chatbot(label="Business Advice from Jeff Bezos")
|
| 66 |
|
| 67 |
+
demo = gr.Interface(
|
| 68 |
+
fn=predict,
|
| 69 |
+
inputs="text",
|
| 70 |
+
outputs="text",
|
| 71 |
+
title="Business Advice from Jeff Bezos",
|
| 72 |
+
theme=gr.themes.Soft(),
|
| 73 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
demo.set_on_chat_load(__attachIp) # Attach IP handler
|
| 76 |
|
| 77 |
+
demo.launch(debug=True)
|