Skip to content

Commit c684a7c

Browse files
committed
Updated openai api calls to support reasoning models
1 parent c92c01a commit c684a7c

5 files changed

Lines changed: 29 additions & 20 deletions

File tree

frontend-next/src/components/documents/document-detail-sheet.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -912,15 +912,15 @@ export function DocumentDetailSheet({
912912

913913
{/* Chat Tab */}
914914
<TabsContent value="chat" className="absolute inset-0 m-0 p-4 flex flex-col data-[state=inactive]:hidden">
915-
<Card className="flex-1 flex flex-col">
916-
<CardHeader className="pb-3">
915+
<Card className="h-full flex flex-col">
916+
<CardHeader className="pb-3 flex-shrink-0">
917917
<CardTitle className="text-lg">Chat with Document</CardTitle>
918918
<CardDescription>
919919
Ask questions about the document content
920920
</CardDescription>
921921
</CardHeader>
922-
<CardContent className="flex-1 flex flex-col">
923-
<ScrollArea className="flex-1 mb-4">
922+
<CardContent className="flex-1 flex flex-col min-h-0 pb-4">
923+
<div className="flex-1 overflow-y-auto mb-4 border rounded-lg p-3 bg-muted/20">
924924
<div className="space-y-4">
925925
{chatMessages.length === 0 ? (
926926
<div className="text-center py-8 text-muted-foreground">
@@ -934,27 +934,35 @@ export function DocumentDetailSheet({
934934
className={`flex ${msg.role === "user" ? "justify-end" : "justify-start"}`}
935935
>
936936
<div
937-
className={`max-w-[80%] p-3 rounded-lg ${
937+
className={`max-w-[85%] p-3 rounded-lg ${
938938
msg.role === "user"
939939
? "bg-primary text-primary-foreground"
940-
: "bg-muted"
940+
: "bg-background border shadow-sm"
941941
}`}
942942
>
943-
{msg.content}
943+
{msg.role === "assistant" ? (
944+
<div className="prose prose-sm dark:prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 prose-table:text-xs prose-th:px-2 prose-td:px-2 prose-th:py-1 prose-td:py-1 prose-table:border prose-th:border prose-td:border">
945+
<ReactMarkdown remarkPlugins={[remarkGfm]}>
946+
{msg.content}
947+
</ReactMarkdown>
948+
</div>
949+
) : (
950+
<span className="whitespace-pre-wrap">{msg.content}</span>
951+
)}
944952
</div>
945953
</div>
946954
))
947955
)}
948956
{isSending && (
949957
<div className="flex justify-start">
950-
<div className="bg-muted p-3 rounded-lg">
958+
<div className="bg-background border shadow-sm p-3 rounded-lg">
951959
<Loader2 className="h-4 w-4 animate-spin" />
952960
</div>
953961
</div>
954962
)}
955963
</div>
956-
</ScrollArea>
957-
<div className="flex gap-2">
964+
</div>
965+
<div className="flex gap-2 flex-shrink-0">
958966
<Input
959967
placeholder="Ask a question..."
960968
value={chatInput}

infra/main-containerapp.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = {
107107
properties: {
108108
accessTier: 'Hot'
109109
}
110-
tags: commonTags
110+
tags: union(commonTags, { SecurityControl: 'Ignore' })
111111
}
112112

113113
// Blob Service
@@ -148,7 +148,7 @@ resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
148148
}
149149
]
150150
}
151-
tags: commonTags
151+
tags: union(commonTags, { SecurityControl: 'Ignore' })
152152
}
153153

154154
// Cosmos DB Database

infra/main.bicep

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = {
111111
properties: {
112112
accessTier: 'Hot'
113113
}
114-
tags: commonTags
114+
tags: union(commonTags, { SecurityControl: 'Ignore' })
115115
}
116116

117117
// Blob Service
@@ -152,7 +152,7 @@ resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
152152
}
153153
]
154154
}
155-
tags: commonTags
155+
tags: union(commonTags, { SecurityControl: 'Ignore' })
156156
}
157157

158158
// Cosmos DB Database
@@ -674,6 +674,11 @@ resource logicApp 'Microsoft.Logic/workflows@2019-05-01' = {
674674
}
675675
}
676676
}
677+
runtimeConfiguration: {
678+
concurrency: {
679+
runs: 5
680+
}
681+
}
677682
}
678683
}
679684
actions: {

src/containerapp/ai_ocr/chains.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,7 @@ def perform_gpt_evaluation_and_enrichment(images: List[str], extracted_data: Dic
421421
response = client.chat.completions.create(
422422
model=config["openai_model_deployment"],
423423
messages=messages,
424-
seed=0,
425-
temperature=0.1, # Lower temperature for more consistent output
426-
response_format={"type": "json_object"} if "gpt-4" in config["openai_model_deployment"].lower() else None
424+
seed=0
427425
)
428426

429427
raw_content = response.choices[0].message.content

src/containerapp/api_routes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,7 @@ async def chat_with_document(request: Request):
567567
# Make the API call
568568
response = client.chat.completions.create(
569569
model=config["openai_model_deployment"],
570-
messages=messages,
571-
max_tokens=1000,
572-
top_p=0.9
570+
messages=messages
573571
)
574572

575573
# Extract the response

0 commit comments

Comments
 (0)