Spaces:
Sleeping
Sleeping
Kate Forsberg
commited on
Commit
·
df7050b
1
Parent(s):
c9e9964
new
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from huggingface_hub import HfApi
|
| 3 |
from typing import Any
|
| 4 |
from griptape.structures import Agent
|
|
@@ -11,6 +12,8 @@ import time
|
|
| 11 |
repo_id = "kateforsberg/gradio-test"
|
| 12 |
api = HfApi()
|
| 13 |
|
|
|
|
|
|
|
| 14 |
def user(user_message, history):
|
| 15 |
history.append([user_message, None])
|
| 16 |
return ("", history)
|
|
@@ -28,7 +31,7 @@ def bot(history):
|
|
| 28 |
agent = Agent(
|
| 29 |
conversation_memory=ConversationMemory(
|
| 30 |
driver=LocalConversationMemoryDriver(
|
| 31 |
-
file_path=
|
| 32 |
)),
|
| 33 |
tools=[Calculator()],
|
| 34 |
rules=[
|
|
@@ -40,12 +43,15 @@ agent = Agent(
|
|
| 40 |
) ]
|
| 41 |
)
|
| 42 |
|
|
|
|
|
|
|
| 43 |
def send_message(message:str, history,) -> Any:
|
| 44 |
response = agent.run(message)
|
| 45 |
return response.output.value
|
| 46 |
|
| 47 |
demo = gr.ChatInterface(
|
| 48 |
-
fn=send_message
|
| 49 |
)
|
| 50 |
demo.launch(
|
| 51 |
-
auth=("griptape","griptaper"))
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from uuid import uuid4 as uuid
|
| 3 |
from huggingface_hub import HfApi
|
| 4 |
from typing import Any
|
| 5 |
from griptape.structures import Agent
|
|
|
|
| 12 |
repo_id = "kateforsberg/gradio-test"
|
| 13 |
api = HfApi()
|
| 14 |
|
| 15 |
+
gr.State(value=f'{str(uuid())}.json')
|
| 16 |
+
|
| 17 |
def user(user_message, history):
|
| 18 |
history.append([user_message, None])
|
| 19 |
return ("", history)
|
|
|
|
| 31 |
agent = Agent(
|
| 32 |
conversation_memory=ConversationMemory(
|
| 33 |
driver=LocalConversationMemoryDriver(
|
| 34 |
+
file_path=gr.State().value
|
| 35 |
)),
|
| 36 |
tools=[Calculator()],
|
| 37 |
rules=[
|
|
|
|
| 43 |
) ]
|
| 44 |
)
|
| 45 |
|
| 46 |
+
gr.State()
|
| 47 |
+
|
| 48 |
def send_message(message:str, history,) -> Any:
|
| 49 |
response = agent.run(message)
|
| 50 |
return response.output.value
|
| 51 |
|
| 52 |
demo = gr.ChatInterface(
|
| 53 |
+
fn=send_message,
|
| 54 |
)
|
| 55 |
demo.launch(
|
| 56 |
+
auth=("griptape","griptaper"))
|
| 57 |
+
|