Commit
·
071ba00
1
Parent(s):
a7ff4a6
Add modal infra
Browse files- __init__.py +3 -0
- agent/agent_config/prompts.py +4 -2
- modal_deploy.py +35 -0
- server/__init__.py +0 -0
- server/main.py +26 -0
__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from . import server
|
| 2 |
+
from . import agent
|
| 3 |
+
from . import tools
|
agent/agent_config/prompts.py
CHANGED
|
@@ -19,7 +19,7 @@ system_message = {
|
|
| 19 |
"Do not fabricate or reuse incorrect descriptions.\n\n"
|
| 20 |
|
| 21 |
"The comment should be well formatted and readable, using Markdown for code blocks and lists where appropriate.\n\n"
|
| 22 |
-
"DO NOT paste or repeat the issue description. DO NOT quote it. Respond entirely in your own words.\n"
|
| 23 |
"You can only use the following tools: fetch_github_issue, get_issue_details, retrieve_context, post_comment.\n"
|
| 24 |
"Whenever an issue involves deals with code or codebase, use the `retrieve_context` tool to get the relevant code snippets or metadata about the codebase to formulate your response.\n"
|
| 25 |
"STRICTLY READ the context that you get back from `retrieve_context` and use it to inform your response.\n"
|
|
@@ -27,6 +27,8 @@ system_message = {
|
|
| 27 |
"DO NOT OVERUSE the context retrieved from `retrieve_context`, only extract relevant context that exactly matches to the current issue.\n\n"
|
| 28 |
"DO NOT OVEREXAGGERATE OR MAKE UP INFORMATION.\n"
|
| 29 |
"Do not attempt to use any other tools such as web_search."
|
| 30 |
-
"DO NOT HALLUCINATE
|
|
|
|
|
|
|
| 31 |
)
|
| 32 |
}
|
|
|
|
| 19 |
"Do not fabricate or reuse incorrect descriptions.\n\n"
|
| 20 |
|
| 21 |
"The comment should be well formatted and readable, using Markdown for code blocks and lists where appropriate.\n\n"
|
| 22 |
+
"DO NOT paste or DO NOT repeat the issue description. DO NOT quote it. Respond entirely in your own words.\n"
|
| 23 |
"You can only use the following tools: fetch_github_issue, get_issue_details, retrieve_context, post_comment.\n"
|
| 24 |
"Whenever an issue involves deals with code or codebase, use the `retrieve_context` tool to get the relevant code snippets or metadata about the codebase to formulate your response.\n"
|
| 25 |
"STRICTLY READ the context that you get back from `retrieve_context` and use it to inform your response.\n"
|
|
|
|
| 27 |
"DO NOT OVERUSE the context retrieved from `retrieve_context`, only extract relevant context that exactly matches to the current issue.\n\n"
|
| 28 |
"DO NOT OVEREXAGGERATE OR MAKE UP INFORMATION.\n"
|
| 29 |
"Do not attempt to use any other tools such as web_search."
|
| 30 |
+
"DO NOT HALLUCINATE"
|
| 31 |
+
"DO NOT MAKE UP TOOLS."
|
| 32 |
+
"NEVER MENTION ANY USERNAME IN THE RESPONSE COMMENT.\n"
|
| 33 |
)
|
| 34 |
}
|
modal_deploy.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from modal import Image, asgi_app, App, Secret
|
| 2 |
+
|
| 3 |
+
app = App("opensorus-server")
|
| 4 |
+
|
| 5 |
+
image = Image.debian_slim().pip_install(
|
| 6 |
+
"fastapi",
|
| 7 |
+
"uvicorn",
|
| 8 |
+
"cryptography==45.0.3",
|
| 9 |
+
"gradio==5.33.0",
|
| 10 |
+
"llama_index==0.12.40",
|
| 11 |
+
"llama_index.llms.mistralai",
|
| 12 |
+
"llama_index.embeddings.mistralai",
|
| 13 |
+
"mistralai==1.8.1",
|
| 14 |
+
"PyJWT==2.10.1",
|
| 15 |
+
"python-dotenv==1.1.0",
|
| 16 |
+
"scikit-learn==1.6.1",
|
| 17 |
+
"requests==2.32.3"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
image = image.add_local_python_source("server")
|
| 21 |
+
image = image.add_local_python_source("agent")
|
| 22 |
+
image = image.add_local_python_source("tools")
|
| 23 |
+
image = image.add_local_python_source("config")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@app.function(image=image, secrets=[Secret.from_name("SECRET")])
|
| 27 |
+
@asgi_app()
|
| 28 |
+
def fastapi_app():
|
| 29 |
+
import sys
|
| 30 |
+
sys.path.append("/root")
|
| 31 |
+
from server.main import app
|
| 32 |
+
return app
|
| 33 |
+
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
app.serve()
|
server/__init__.py
ADDED
|
File without changes
|
server/main.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException
|
| 2 |
+
from agent.core import run_agent
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
@app.post('/webhook')
|
| 7 |
+
async def check_payload(payload: dict):
|
| 8 |
+
if "action" in payload:
|
| 9 |
+
if payload["action"] == "created":
|
| 10 |
+
comment_body = payload["comment"]["body"] if "comment" in payload else ""
|
| 11 |
+
if "@opensorus" in comment_body.lower():
|
| 12 |
+
print("This issue is assigned to OpenSorus Agent.")
|
| 13 |
+
issue_url = payload["issue"]["url"]
|
| 14 |
+
print("URL", issue_url)
|
| 15 |
+
branch_name = payload["repository"]["default_branch"]
|
| 16 |
+
print("Branch Name", branch_name)
|
| 17 |
+
result = await run_agent(issue_url, branch_name)
|
| 18 |
+
return {"message": result or "This issue is assigned to OpenSorus Agent."}
|
| 19 |
+
else:
|
| 20 |
+
raise HTTPException(status_code=400, detail="Unknown action.")
|
| 21 |
+
else:
|
| 22 |
+
raise HTTPException(status_code=400, detail="No valid payload.")
|
| 23 |
+
|
| 24 |
+
@app.get('/health')
|
| 25 |
+
def health_check():
|
| 26 |
+
return {"status": "Hello World!, I am alive!"}
|