MrTechie commited on
Commit
d2b08fc
·
1 Parent(s): 2932504

updated the api schema

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. agent/llm.py +2 -2
  3. new_api_schema.md +75 -0
.gitignore CHANGED
@@ -3,3 +3,4 @@ __pycache__/
3
  venv/
4
  *.db
5
  *.sqlite
 
 
3
  venv/
4
  *.db
5
  *.sqlite
6
+ .env
agent/llm.py CHANGED
@@ -30,7 +30,7 @@ if not HF_TOKEN:
30
  llm_chain: Runnable = ChatOpenAI(
31
  model="deepseek-chat", # Optional for HF OpenAI-compatible endpoints, but kept for clarity
32
  openai_api_base="https://oaitzvyxm6614ekn.us-east-1.aws.endpoints.huggingface.cloud/v1/",
33
- openai_api_key=HF_TOKEN,
34
  temperature=0.3,
35
  max_tokens=8192,
36
  streaming=True,
@@ -50,7 +50,7 @@ llm_chain: Runnable = ChatOpenAI(
50
  # llm_chain: Runnable = ChatOpenAI(
51
  # model="deepseek-chat", # Optional for HF OpenAI-compatible endpoints, but kept for clarity
52
  # openai_api_base="https://qwryad273mlndckn.us-east-1.aws.endpoints.huggingface.cloud/v1/",
53
- # openai_api_key=HF_TOKEN,
54
  # temperature=0.3,
55
  # max_tokens=8192,
56
  # streaming=True,
 
30
  llm_chain: Runnable = ChatOpenAI(
31
  model="deepseek-chat", # Optional for HF OpenAI-compatible endpoints, but kept for clarity
32
  openai_api_base="https://oaitzvyxm6614ekn.us-east-1.aws.endpoints.huggingface.cloud/v1/",
33
+ openai_api_key=os.getenv("HF_TOKEN"),
34
  temperature=0.3,
35
  max_tokens=8192,
36
  streaming=True,
 
50
  # llm_chain: Runnable = ChatOpenAI(
51
  # model="deepseek-chat", # Optional for HF OpenAI-compatible endpoints, but kept for clarity
52
  # openai_api_base="https://qwryad273mlndckn.us-east-1.aws.endpoints.huggingface.cloud/v1/",
53
+ # openai_api_key=os.getenv("HF_TOKEN"),
54
  # temperature=0.3,
55
  # max_tokens=8192,
56
  # streaming=True,
new_api_schema.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AgreeUpon API v1 Schema
2
+
3
+ Base URL: `/api/v1`
4
+
5
+ ## Authentication `/auth`
6
+ | Method | Path | Body | Success 200 |
7
+ |--------|------|------|-------------|
8
+ | POST | /auth/register | UserCreate | UserRead |
9
+ | POST | /auth/login | UserLogin | Token |
10
+ | POST | /auth/refresh | — | Token |
11
+ | POST | /auth/logout | — | `{ok:true}` |
12
+
13
+ ## Conversations `/conversations`
14
+ | Method | Path | Description | Success |
15
+ |--------|------|-------------|---------|
16
+ | POST | /conversations | create new conversation | Conversation |
17
+ | GET | /conversations | list conversations (`limit,offset`) | List[Conversation] |
18
+ | GET | /conversations/{id} | fetch single conversation | Conversation |
19
+ | DELETE | /conversations/{id} | delete conversation | 204 |
20
+
21
+ ## Agent interaction (nested)
22
+ | Method | Path | Body | Success |
23
+ |--------|------|------|---------|
24
+ | POST | /conversations/{id}/agent/message | MessageCreate | AgentReply |
25
+ | GET | /conversations/{id}/agent/stream?prompt=… | SSE | events: reply, document, done |
26
+
27
+ ## Documents (nested)
28
+ | Method | Path | Body | Success |
29
+ |--------|------|------|---------|
30
+ | GET | /conversations/{id}/document | — | Document |
31
+ | PUT | /conversations/{id}/document | DocumentUpdate | Document |
32
+
33
+ ## Standard envelope
34
+ ```json
35
+ {
36
+ "data": { … }, // null on error
37
+ "error": {
38
+ "code": "not_found",
39
+ "message": "Conversation not found"
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## Core Models (Python / Pydantic)
45
+ ```python
46
+ class UserCreate(BaseModel):
47
+ username: constr(min_length=3, max_length=30)
48
+ password: constr(min_length=8)
49
+
50
+ class Token(BaseModel):
51
+ access_token: str
52
+ token_type: str = "bearer"
53
+
54
+ class Conversation(BaseModel):
55
+ id: int
56
+ created_at: datetime
57
+
58
+ class MessageCreate(BaseModel):
59
+ content: constr(min_length=1, max_length=10_000)
60
+
61
+ class AgentReply(BaseModel):
62
+ assistant_reply: str
63
+ document: Optional[str]
64
+
65
+ class Document(BaseModel):
66
+ id: int
67
+ conversation_id: int
68
+ doc_type: Literal["contract", "memo", "unknown"]
69
+ content: str
70
+ updated_at: datetime
71
+ ```
72
+
73
+ ---
74
+
75
+ This schema is versioned, REST-ful, strongly typed, self-documenting, and prepared for expansion.