panda992 commited on
Commit
70a0777
·
1 Parent(s): 5137ec1

Add app.py and requirements.txt, update README

Browse files
Files changed (3) hide show
  1. README.md +31 -8
  2. app.py +55 -0
  3. requirements.txt +1 -0
README.md CHANGED
@@ -1,14 +1,37 @@
1
  ---
2
- title: Medical Ai
3
- emoji:
4
- colorFrom: blue
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.33.0
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
- short_description: medical ai for helping patients
 
 
 
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Simple Echo Agent Demo
3
+ emoji: 👋
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 4.31.0 # Or your Gradio version
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
+ tags:
12
+ - agent-demo-track # IMPORTANT for Track 3
13
+ - gradio
14
+ - hackathon
15
  ---
16
 
17
+ # Simple Echo Agent Demo
18
+
19
+ **Hackathon Track:** Agentic Demo Showcase (`agent-demo-track`)
20
+
21
+ ## Description
22
+
23
+ This is a very simple Gradio app for the Agents-MCP-Hackathon.
24
+ It demonstrates a basic "agent" that just echoes back whatever you type, with a prefix.
25
+
26
+ ## How to Use
27
+
28
+ 1. Type a message in the input box.
29
+ 2. Click the "Echo Message" button.
30
+ 3. See the agent's response.
31
+
32
+ ## Video Overview
33
+
34
+ * **[YOUR VIDEO LINK HERE]** - *You MUST create a short video showing your app and link it here.*
35
+ * _Example: A screen recording of you typing and seeing the echo._
36
+
37
+ ---
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time # For a more "natural" typing simulation
3
+
4
+ def echo_chat_function(message, history):
5
+ """
6
+ Responds to a user's message in a chat context.
7
+ 'message' is the latest user input.
8
+ 'history' is a list of previous [user_message, bot_message] pairs.
9
+ """
10
+ if not message:
11
+ # In a chat, if the user sends an empty message,
12
+ # you might want to prompt them or do nothing.
13
+ return "Agent: Hmm, did you mean to send something?"
14
+
15
+ # This is where you would put your agent's logic (e.g., LLM calls).
16
+ # For now, we'll just echo with a prefix.
17
+ response_prefix = "Agent Echo: "
18
+ full_response = f"{response_prefix}{message}"
19
+
20
+ # Simulate the agent "typing" for a better chat feel
21
+ # gr.ChatInterface handles streaming if you yield partial responses
22
+ partial_response = ""
23
+ for char in full_response:
24
+ partial_response += char
25
+ time.sleep(0.03) # Small delay for each character
26
+ yield partial_response # Yield intermediate parts of the response
27
+
28
+ # Create the Gradio Chat Interface
29
+ chat_iface = gr.ChatInterface(
30
+ fn=echo_chat_function, # The Python function to call for responses
31
+ chatbot=gr.Chatbot(
32
+ height=400,
33
+ # The deprecation warning you saw earlier is for the underlying data format.
34
+ # When using ChatInterface, it generally handles this for you.
35
+ # If you were manually populating a Chatbot, you'd use:
36
+ # value=[{"role": "user", "content": "Hi"}], type="messages"
37
+ # But ChatInterface handles this internally.
38
+ ),
39
+ textbox=gr.Textbox(placeholder="Type your message here and press Enter...",
40
+ container=False, scale=7), # Input textbox configuration
41
+ title="Simple Echo Chat Agent ",
42
+ description="""
43
+ This is a simple chat interface for the Agents-MCP-Hackathon.
44
+ Type a message, and the 'agent' will echo it back.
45
+ This version includes specific button configurations suitable for newer Gradio versions.
46
+ """,
47
+ examples=[["Hello!"], ["How are you today?"]], # Example prompts
48
+ cache_examples=False, # Don't cache examples for dynamic functions usually
49
+
50
+ submit_btn="Send" # Text for the submit button (optional, Enter also works)
51
+ )
52
+
53
+ # Launch the app
54
+ if __name__ == "__main__":
55
+ chat_iface.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio