Skip to content

Commit

Permalink
endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
BRama10 committed Nov 16, 2024
1 parent f4ac246 commit 544ec33
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 1 addition & 4 deletions aios/llm_cores/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
# abc allows to make abstract classes
from abc import ABC, abstractmethod


from cerebrum.utils.chat import Query
from cerebrum.utils.llm import generator_tool_call_id
from aios.utils.id_generator import generator_tool_call_id
from pyopenagi.utils.chat_template import Query
from pyopenagi.utils.chat_template import LLMQuery as Query


class BaseLLM(ABC):
Expand Down
20 changes: 20 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import OrderedDict
from fastapi import Depends, FastAPI, Query
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel

from aios.hooks.modules.scheduler import useFIFOScheduler
from aios.hooks.modules.agent import useFactory
Expand All @@ -15,6 +16,8 @@
from aios.core.schema import CoreSchema
from aios.hooks.types.parser import ParserQuery

from aios.llm_cores.adapter import LLMAdapter

from aios.utils.utils import (
parse_global_args,
)
Expand All @@ -29,6 +32,8 @@

import json

from pyopenagi.utils.chat_template import LLMQuery

load_dotenv()

app = FastAPI()
Expand Down Expand Up @@ -126,6 +131,21 @@
async def set_kernel(req: LLMParams):
setLLMState(useCore(**req))

class LLMCoreCallParams(BaseModel):
llm_name: str
query: LLMQuery

@app.post("/call_llm_core")
async def call_llm_core(req: LLMCoreCallParams):
llm = LLMAdapter(req.llm_name)
core = llm.get_model()

res = core.execute(req.query)

return {
'response': res
}


@app.post("/add_agent")
async def add_agent(
Expand Down

0 comments on commit 544ec33

Please sign in to comment.