Skip to content

Commit 0c18573

Browse files
Change in backend code to get PR review from copilot
1 parent ab75ecd commit 0c18573

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/backend/history/cosmosdbservice.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,36 @@ def __init__(
2525
)
2626
except exceptions.CosmosHttpResponseError as e:
2727
if e.status_code == 401:
28-
raise ValueError("Invalid credentials") from e
28+
raise ValueError("Unauthorized") from e
2929
else:
30-
raise ValueError("Invalid CosmosDB endpoint") from e
30+
print("Cosmos error")
31+
raise ValueError("Something went wrong!") from e
3132

3233
try:
3334
self.database_client = self.cosmosdb_client.get_database_client(
3435
database_name
3536
)
3637
except exceptions.CosmosResourceNotFoundError:
3738
raise ValueError("Invalid CosmosDB database name")
39+
except:
40+
pass
3841

3942
try:
4043
self.container_client = self.database_client.get_container_client(
4144
container_name
4245
)
4346
except exceptions.CosmosResourceNotFoundError:
4447
raise ValueError("Invalid CosmosDB container name")
48+
except:
49+
pass
4550

4651
async def ensure(self):
4752
if (
4853
not self.cosmosdb_client
4954
or not self.database_client
5055
or not self.container_client
5156
):
52-
return False, "CosmosDB client not initialized correctly"
57+
return False, "client not initialized"
5358
try:
5459
await self.database_client.read()
5560
except Exception:
@@ -73,6 +78,7 @@ async def create_conversation(self, user_id, title=""):
7378
"updatedAt": datetime.utcnow().isoformat(),
7479
"userId": user_id,
7580
"title": title,
81+
"metadata": {}
7682
}
7783
# TODO: add some error handling based on the output of the upsert_item call
7884
resp = await self.container_client.upsert_item(conversation)

src/frontend/src/pages/document/Document.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ const Document = (): JSX.Element => {
1919
setIsLoading(true); // Step 2
2020
try {
2121
const response = await documentRead(id);
22-
const data = await response.text() //response.json();
23-
setDocument(data as any); //made changes here with "as any"
22+
const data = await response.json();
23+
setDocument(data);
2424
} catch (error) {
25-
console.error("Error:",error); // added "Error:"
25+
console.error(error);
2626
setDocument(null);
2727
} finally {
2828
setIsLoading(false); // Step 3
2929
}
3030
};
3131

3232
if (params.id) {
33-
getDocument(params.id as string); //unnecessary cast
33+
getDocument(params.id);
3434
}
3535
}, [params.id]);
3636

@@ -41,7 +41,7 @@ const Document = (): JSX.Element => {
4141
) : document ? (
4242
<p>{document.content}</p>
4343
) : (
44-
<h1>Document not found</h1>
44+
<h1>Document not found. Please try again.</h1>
4545
)}
4646
</>
4747
);

0 commit comments

Comments
 (0)