-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from hitsz-ids/developing
Developing
- Loading branch information
Showing
9 changed files
with
113 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,3 +68,4 @@ def query_schema(self): | |
table_comment=table[1], | ||
) | ||
self.context.sync_instruction(instruction) | ||
cursor.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +0,0 @@ | ||
import fastapi | ||
from overrides import overrides | ||
|
||
from airda.agent.env import DataAgentEnv | ||
from airda.server import WebFrameworkServer | ||
from airda.server.api.api import APIImpl | ||
from airda.server.protocol import ChatCompletionRequest | ||
|
||
|
||
class DataAgentServer(WebFrameworkServer): | ||
def __init__(self, host="0.0.0.0", port=8888): | ||
super().__init__(host, port) | ||
self.router = None | ||
|
||
def init_api(self): | ||
return APIImpl() | ||
|
||
@overrides | ||
def create_app(self): | ||
return fastapi.FastAPI(debug=True) | ||
|
||
@overrides | ||
def run_server(self): | ||
import uvicorn | ||
|
||
uvicorn.run(self.app, host=self.host, port=self.port, log_level="info") | ||
|
||
@overrides | ||
def add_routes(self): | ||
self.router = fastapi.APIRouter() | ||
self.router.add_api_route( | ||
"/v1/chat/completions", | ||
self.create_completion, | ||
methods=["POST"], | ||
tags=["chat completions"], | ||
) | ||
self.app.include_router(self.router) | ||
|
||
async def create_completion(self, request: ChatCompletionRequest): | ||
return await self._api.create_completion(request) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import fastapi | ||
from overrides import overrides | ||
|
||
from airda.server import WebFrameworkServer | ||
from airda.server.api.api import APIImpl | ||
from airda.server.protocol import AddDatasourceRequest, ChatCompletionRequest | ||
|
||
|
||
class AirdaServer(WebFrameworkServer): | ||
def __init__(self, host="0.0.0.0", port=8888): | ||
super().__init__(host, port) | ||
self.router = None | ||
|
||
def init_api(self): | ||
return APIImpl() | ||
|
||
@overrides | ||
def create_app(self): | ||
return fastapi.FastAPI(debug=True) | ||
|
||
@overrides | ||
def run_server(self): | ||
import uvicorn | ||
|
||
uvicorn.run(self.app, host=self.host, port=self.port, log_level="info") | ||
|
||
@overrides | ||
def add_routes(self): | ||
self.router = fastapi.APIRouter() | ||
self.router.add_api_route( | ||
"/v1/chat/completions", | ||
self.create_completion, | ||
methods=["POST"], | ||
tags=["chat completions"], | ||
) | ||
self.router.add_api_route( | ||
"/v1/datasource/add", | ||
self.create_completion, | ||
methods=["POST"], | ||
tags=["datasource add"], | ||
) | ||
self.app.include_router(self.router) | ||
|
||
async def create_completion(self, request: ChatCompletionRequest): | ||
return await self._api.create_completion(request) | ||
|
||
def add_datasource(self, request: AddDatasourceRequest): | ||
return self._api.add_datasource(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from airda.server.protocol import ChatCompletionRequest | ||
from airda.server.protocol import AddDatasourceRequest, ChatCompletionRequest | ||
|
||
|
||
class API(ABC): | ||
@abstractmethod | ||
async def create_completion(self, request: ChatCompletionRequest): | ||
pass | ||
|
||
@abstractmethod | ||
async def add_datasource(self, request: AddDatasourceRequest): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters