Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .github/workflows/ci.yml +4 -4
- .github/workflows/update_space.yml +3 -3
- README.md +3 -0
- src/opensymbiose/gradio/app.py +16 -4
- uv.lock +0 -0
.github/workflows/ci.yml
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
name: Deploy Documentation
|
2 |
on:
|
3 |
push:
|
4 |
-
|
5 |
-
-
|
6 |
-
- main
|
7 |
permissions:
|
8 |
contents: write
|
9 |
jobs:
|
10 |
deploy:
|
11 |
runs-on: ubuntu-latest
|
|
|
12 |
steps:
|
13 |
- uses: actions/checkout@v4
|
14 |
- name: Configure Git Credentials
|
@@ -26,4 +26,4 @@ jobs:
|
|
26 |
restore-keys: |
|
27 |
mkdocs-material-
|
28 |
- run: pip install mkdocs-material mkdocstrings mkdocstrings-python mkdocs-include-markdown-plugin
|
29 |
-
- run: mkdocs gh-deploy --force
|
|
|
1 |
name: Deploy Documentation
|
2 |
on:
|
3 |
push:
|
4 |
+
tags:
|
5 |
+
- '*'
|
|
|
6 |
permissions:
|
7 |
contents: write
|
8 |
jobs:
|
9 |
deploy:
|
10 |
runs-on: ubuntu-latest
|
11 |
+
if: startsWith(github.ref, 'refs/tags/') && github.event.base_ref == 'refs/heads/master'
|
12 |
steps:
|
13 |
- uses: actions/checkout@v4
|
14 |
- name: Configure Git Credentials
|
|
|
26 |
restore-keys: |
|
27 |
mkdocs-material-
|
28 |
- run: pip install mkdocs-material mkdocstrings mkdocstrings-python mkdocs-include-markdown-plugin
|
29 |
+
- run: mkdocs gh-deploy --force
|
.github/workflows/update_space.yml
CHANGED
@@ -2,13 +2,13 @@ name: Deploy to HuggingFace
|
|
2 |
|
3 |
on:
|
4 |
push:
|
5 |
-
|
6 |
-
-
|
7 |
-
- master
|
8 |
|
9 |
jobs:
|
10 |
build:
|
11 |
runs-on: ubuntu-latest
|
|
|
12 |
|
13 |
steps:
|
14 |
- name: Checkout
|
|
|
2 |
|
3 |
on:
|
4 |
push:
|
5 |
+
tags:
|
6 |
+
- '*'
|
|
|
7 |
|
8 |
jobs:
|
9 |
build:
|
10 |
runs-on: ubuntu-latest
|
11 |
+
if: startsWith(github.ref, 'refs/tags/') && github.event.base_ref == 'refs/heads/master'
|
12 |
|
13 |
steps:
|
14 |
- name: Checkout
|
README.md
CHANGED
@@ -3,11 +3,14 @@ title: opensymbiose
|
|
3 |
app_file: src/opensymbiose/gradio/app.py
|
4 |
sdk: gradio
|
5 |
sdk_version: 5.31.0
|
|
|
6 |
---
|
7 |
# OpenSymbiose: Open Source Biotechnology AI Agent
|
8 |
|
9 |
OpenSymbiose is an open-source biotechnology / biology research AI agent designed to support researcher.
|
10 |
|
|
|
|
|
11 |
Creator and Maintainer: [**Corentin Meyer**, PhD](https://cmeyer.fr/) - <[email protected]>
|
12 |
|
13 |
## Installation
|
|
|
3 |
app_file: src/opensymbiose/gradio/app.py
|
4 |
sdk: gradio
|
5 |
sdk_version: 5.31.0
|
6 |
+
python_version: 3.13
|
7 |
---
|
8 |
# OpenSymbiose: Open Source Biotechnology AI Agent
|
9 |
|
10 |
OpenSymbiose is an open-source biotechnology / biology research AI agent designed to support researcher.
|
11 |
|
12 |
+
[DOCUMENTATION](https://lambda-science.github.io/OpenSymbiose/) - [DEMO ON HUGGINGFACE](https://huggingface.co/spaces/corentinm7/opensymbiose) - [CODE REPO](https://github.com/lambda-science/OpenSymbiose)
|
13 |
+
|
14 |
Creator and Maintainer: [**Corentin Meyer**, PhD](https://cmeyer.fr/) - <[email protected]>
|
15 |
|
16 |
## Installation
|
src/opensymbiose/gradio/app.py
CHANGED
@@ -9,14 +9,19 @@ from mistralai import Mistral, ToolReferenceChunk
|
|
9 |
import opensymbiose.config
|
10 |
from opensymbiose.agents.create_agents import get_agents
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
logger = logging.getLogger(__name__)
|
13 |
client = Mistral(api_key=opensymbiose.config.MISTRAL_API_KEY)
|
14 |
model = "mistral-medium-latest"
|
15 |
|
16 |
-
|
17 |
-
def get_mistral_answer(message: str, history):
|
18 |
# Start global execution timer
|
19 |
global_start_time = time.time()
|
|
|
20 |
|
21 |
# Dictionary to track tool execution times
|
22 |
tool_timers = {}
|
@@ -32,14 +37,17 @@ def get_mistral_answer(message: str, history):
|
|
32 |
yield messages
|
33 |
full_response = ""
|
34 |
for chunk in stream_response:
|
35 |
-
|
36 |
if chunk.event == "message.output.delta":
|
37 |
if isinstance(chunk.data.content, str):
|
38 |
full_response += chunk.data.content
|
39 |
if isinstance(chunk.data.content, ToolReferenceChunk):
|
40 |
full_response += f"([{chunk.data.content.title}]({chunk.data.content.url})) "
|
41 |
# Update the last message with the current full response
|
42 |
-
messages[-1]
|
|
|
|
|
|
|
43 |
yield messages
|
44 |
elif chunk.event == "tool.execution.started":
|
45 |
# Start timer for this tool
|
@@ -101,10 +109,12 @@ def get_mistral_answer(message: str, history):
|
|
101 |
metadata={"title": f"✅ Conversation response complete.",
|
102 |
"log": f"Tokens: Prompt: {chunk.data.usage.prompt_tokens}, Completion: {chunk.data.usage.completion_tokens}, Total: {chunk.data.usage.total_tokens} Connectors: {chunk.data.usage.connector_tokens}",
|
103 |
"duration": round(global_duration, 2)})))
|
|
|
104 |
yield messages
|
105 |
elif chunk.event == "conversation.response.error":
|
106 |
# Add a new message for conversation response error
|
107 |
error_message = f"Error: {chunk.data.message} (Code: {chunk.data.code})"
|
|
|
108 |
messages.append(asdict(ChatMessage(role="assistant", content="",
|
109 |
metadata={"title": f"❌ {error_message}"})))
|
110 |
yield messages
|
@@ -127,4 +137,6 @@ with gr.Blocks() as demo:
|
|
127 |
)
|
128 |
|
129 |
if __name__ == "__main__":
|
|
|
|
|
130 |
demo.launch()
|
|
|
9 |
import opensymbiose.config
|
10 |
from opensymbiose.agents.create_agents import get_agents
|
11 |
|
12 |
+
logging.basicConfig(
|
13 |
+
level=logging.WARNING,
|
14 |
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
15 |
+
handlers=[logging.StreamHandler()]
|
16 |
+
)
|
17 |
logger = logging.getLogger(__name__)
|
18 |
client = Mistral(api_key=opensymbiose.config.MISTRAL_API_KEY)
|
19 |
model = "mistral-medium-latest"
|
20 |
|
21 |
+
def get_mistral_answer(message: str, history = None):
|
|
|
22 |
# Start global execution timer
|
23 |
global_start_time = time.time()
|
24 |
+
logger.info(f"Processing message: {message}")
|
25 |
|
26 |
# Dictionary to track tool execution times
|
27 |
tool_timers = {}
|
|
|
37 |
yield messages
|
38 |
full_response = ""
|
39 |
for chunk in stream_response:
|
40 |
+
logger.info(f"Chunk: {chunk}")
|
41 |
if chunk.event == "message.output.delta":
|
42 |
if isinstance(chunk.data.content, str):
|
43 |
full_response += chunk.data.content
|
44 |
if isinstance(chunk.data.content, ToolReferenceChunk):
|
45 |
full_response += f"([{chunk.data.content.title}]({chunk.data.content.url})) "
|
46 |
# Update the last message with the current full response
|
47 |
+
if messages and messages[-1].get("role") == "assistant" and not messages[-1].get("metadata"):
|
48 |
+
messages[-1] = asdict(ChatMessage(role="assistant", content=full_response))
|
49 |
+
else:
|
50 |
+
messages.append(asdict(ChatMessage(role="assistant", content=full_response)))
|
51 |
yield messages
|
52 |
elif chunk.event == "tool.execution.started":
|
53 |
# Start timer for this tool
|
|
|
109 |
metadata={"title": f"✅ Conversation response complete.",
|
110 |
"log": f"Tokens: Prompt: {chunk.data.usage.prompt_tokens}, Completion: {chunk.data.usage.completion_tokens}, Total: {chunk.data.usage.total_tokens} Connectors: {chunk.data.usage.connector_tokens}",
|
111 |
"duration": round(global_duration, 2)})))
|
112 |
+
logger.info(f"Conversation response complete. Duration: {round(global_duration, 2)}s, Total tokens: {chunk.data.usage.total_tokens}")
|
113 |
yield messages
|
114 |
elif chunk.event == "conversation.response.error":
|
115 |
# Add a new message for conversation response error
|
116 |
error_message = f"Error: {chunk.data.message} (Code: {chunk.data.code})"
|
117 |
+
logger.error(f"Conversation response error: {error_message}")
|
118 |
messages.append(asdict(ChatMessage(role="assistant", content="",
|
119 |
metadata={"title": f"❌ {error_message}"})))
|
120 |
yield messages
|
|
|
137 |
)
|
138 |
|
139 |
if __name__ == "__main__":
|
140 |
+
logger.setLevel(logging.INFO)
|
141 |
+
logging.getLogger().setLevel(logging.INFO)
|
142 |
demo.launch()
|
uv.lock
CHANGED
The diff for this file is too large to render.
See raw diff
|
|