Add rest-api example (#889)
This commit is contained in:
45
examples/rest-api/models.py
Normal file
45
examples/rest-api/models.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
from sqlalchemy import Column, String, Integer
|
||||
from database import Base
|
||||
|
||||
|
||||
class QueryApp(BaseModel):
|
||||
query: str = Field("", description="The query that you want to ask the App.")
|
||||
|
||||
model_config = {
|
||||
"json_schema_extra": {
|
||||
"example": {
|
||||
"query": "Who is Elon Musk?",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SourceApp(BaseModel):
|
||||
source: str = Field("", description="The source that you want to add to the App.")
|
||||
data_type: Optional[str] = Field("", description="The type of data to add, remove it for autosense.")
|
||||
|
||||
model_config = {"json_schema_extra": {"example": {"source": "https://en.wikipedia.org/wiki/Elon_Musk"}}}
|
||||
|
||||
|
||||
class DeployAppRequest(BaseModel):
|
||||
api_key: str = Field("", description="The Embedchain API key for App deployments.")
|
||||
|
||||
model_config = {"json_schema_extra": {"example": {"api_key": "ec-xxx"}}}
|
||||
|
||||
|
||||
class MessageApp(BaseModel):
|
||||
message: str = Field("", description="The message that you want to send to the App.")
|
||||
|
||||
|
||||
class DefaultResponse(BaseModel):
|
||||
response: str
|
||||
|
||||
|
||||
class AppModel(Base):
|
||||
__tablename__ = "apps"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
app_id = Column(String, unique=True, index=True)
|
||||
config = Column(String, unique=True, index=True)
|
||||
Reference in New Issue
Block a user