Update app.py
Browse files
app.py
CHANGED
|
@@ -57,21 +57,22 @@ You are an expert programming assistant. Your role is to provide code suggestion
|
|
| 57 |
|
| 58 |
**CONTEXT HANDLING RULES (Follow these strictly):**
|
| 59 |
- **Conversation Summary:** At the end of every response, you MUST provide an updated, concise `conversationSummary` based on the entire chat history provided. This summary helps you maintain context.
|
| 60 |
-
- **Code Suggestions:** When suggesting code, always enclose it in appropriate markdown code blocks (e.g., ```python\n...\n```).
|
| 61 |
- **Language Adaptation:** Adjust your suggestions, code, and explanations to the programming language specified in the 'language' field of the 'AssistantState'.
|
| 62 |
|
| 63 |
STRICT OUTPUT FORMAT (JSON ONLY):
|
| 64 |
Return a single JSON object with the following keys:
|
| 65 |
-
- assistant_reply: string // a natural language reply
|
| 66 |
- state_updates: object // updates to the internal state, must include: language, conversationSummary
|
| 67 |
- suggested_tags: array of strings // a list of 1-3 relevant tags for the assistant_reply
|
| 68 |
|
| 69 |
Rules:
|
| 70 |
- ALWAYS include `assistant_reply` as a non-empty string.
|
|
|
|
| 71 |
- Do NOT produce any text outside the JSON object.
|
| 72 |
-
- Be concise in `assistant_reply`.
|
| 73 |
"""
|
| 74 |
|
|
|
|
| 75 |
def extract_json_from_llm_response(raw_response: str) -> dict:
|
| 76 |
default = {
|
| 77 |
"assistant_reply": "I'm sorry — I couldn't understand that. Could you please rephrase?",
|
|
|
|
| 57 |
|
| 58 |
**CONTEXT HANDLING RULES (Follow these strictly):**
|
| 59 |
- **Conversation Summary:** At the end of every response, you MUST provide an updated, concise `conversationSummary` based on the entire chat history provided. This summary helps you maintain context.
|
|
|
|
| 60 |
- **Language Adaptation:** Adjust your suggestions, code, and explanations to the programming language specified in the 'language' field of the 'AssistantState'.
|
| 61 |
|
| 62 |
STRICT OUTPUT FORMAT (JSON ONLY):
|
| 63 |
Return a single JSON object with the following keys:
|
| 64 |
+
- assistant_reply: string // a natural language reply TO THE USER, INCLUDING ANY REQUESTED CODE BLOCK(S).
|
| 65 |
- state_updates: object // updates to the internal state, must include: language, conversationSummary
|
| 66 |
- suggested_tags: array of strings // a list of 1-3 relevant tags for the assistant_reply
|
| 67 |
|
| 68 |
Rules:
|
| 69 |
- ALWAYS include `assistant_reply` as a non-empty string.
|
| 70 |
+
- If the user is asking for code, the code MUST be enclosed in appropriate markdown code blocks (e.g., ```python\n...\n```) and placed within the `assistant_reply` string.
|
| 71 |
- Do NOT produce any text outside the JSON object.
|
| 72 |
+
- Be concise in the non-code parts of `assistant_reply`.
|
| 73 |
"""
|
| 74 |
|
| 75 |
+
|
| 76 |
def extract_json_from_llm_response(raw_response: str) -> dict:
|
| 77 |
default = {
|
| 78 |
"assistant_reply": "I'm sorry — I couldn't understand that. Could you please rephrase?",
|