Skip to content

Commit

Permalink
added fastapi test
Browse files Browse the repository at this point in the history
  • Loading branch information
areibman committed Nov 25, 2024
1 parent 2934e56 commit 8434cc6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
40 changes: 40 additions & 0 deletions tests/core_manual_tests/api_server/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import agentops
from fastapi import FastAPI
import uvicorn
from dotenv import load_dotenv
from agentops import record_tool
from openai import OpenAI
import time

load_dotenv()

openai = OpenAI()
agentops.init(auto_start_session=False)
app = FastAPI()


@app.get("/completion")
def completion():
start_time = time.time()

session = agentops.start_session(tags=["api-server-test"])

@record_tool(tool_name="foo")
def foo(x: str):
print(x)

foo("Hello")

session.end_session(end_state="Success")

end_time = time.time()
execution_time = end_time - start_time

return {
"response": 'Done',
"execution_time_seconds": execution_time
}


if __name__ == "__main__":
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)
39 changes: 0 additions & 39 deletions tests/core_manual_tests/api_server/server.py

This file was deleted.

0 comments on commit 8434cc6

Please sign in to comment.