Skip to content

Commit bf9850c

Browse files
committed
Merge remote-tracking branch 'origin/main' into backend/safety_features
2 parents b736d3f + 5db23dc commit bf9850c

17 files changed

Lines changed: 594 additions & 95 deletions

File tree

backend/app/llm/openai/provider.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def extract_keywords(self, user_text: str) -> List[str]:
4141
reasoning={"effort": "low"},
4242
input=[
4343
{
44-
"role": "developer",
44+
"role": "system",
4545
"content": KEYWORD_PROMPT,
4646
},
4747
{
@@ -59,9 +59,9 @@ async def extract_keywords(self, user_text: str) -> List[str]:
5959
return keyword_list
6060

6161
async def extract_keywords_from_pdf(
62-
self,
63-
pdf_text: str,
64-
query: Optional[str] = None,
62+
self,
63+
pdf_text: str,
64+
query: Optional[str] = None,
6565
) -> List[str]:
6666
"""
6767
Extracts a list of search queries from the full text of a paper and an optional query.
@@ -79,7 +79,7 @@ async def extract_keywords_from_pdf(
7979
reasoning={"effort": "medium"},
8080
input=[
8181
{
82-
"role": "developer",
82+
"role": "system",
8383
"content": PDF_KEYWORD_PROMPT,
8484
},
8585
{
@@ -141,7 +141,7 @@ async def summarise_paper(self, paper_text: str, query: str) -> Dict[str, Any]:
141141
reasoning={"effort": "medium"},
142142
input=[
143143
{
144-
"role": "developer",
144+
"role": "system",
145145
"content": prompt_content,
146146
},
147147
{
@@ -175,7 +175,7 @@ async def summarise_paper(self, paper_text: str, query: str) -> Dict[str, Any]:
175175
return data
176176

177177
async def chat_about_paper(
178-
self, paper_text: str, user_query: str, chat_history: List[Dict[str, str]]
178+
self, paper_text: str, user_query: str, chat_history: List[Dict[str, str]]
179179
) -> str:
180180
"""
181181
Handles a chat turn using the full paper text as context.

backend/app/routes/paper_routes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
from app.schemas.paper_dto import (
1111
PaperChatRequest,
1212
PaperChatResponse,
13+
PaperSummaryRequest,
14+
PaperSummaryResponse,
1315
)
14-
from app.schemas.paper_dto import PaperSummaryRequest, PaperSummaryResponse
1516
from app.services.paper_service import PaperService
1617

1718
logger = logging.getLogger("inquiro")
@@ -72,8 +73,8 @@ async def chat_with_paper(
7273
summary="Get the PDF of the specified paper",
7374
)
7475
async def get_paper_pdf(
75-
paper_id: int,
76-
db: AsyncSession = Depends(get_db),
76+
paper_id: int,
77+
db: AsyncSession = Depends(get_db),
7778
) -> StreamingResponse:
7879
"""
7980
Stream the PDF file of the specified paper.

frontend/src/api/.openapi-generator/FILES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ models/condition-group-children-inner.ts
1414
models/condition-group.ts
1515
models/httpvalidation-error.ts
1616
models/index.ts
17+
models/location-inner.ts
1718
models/login-request.ts
1819
models/login-response.ts
1920
models/paper-chat-request.ts
@@ -32,5 +33,4 @@ models/search-response.ts
3233
models/text-condition.ts
3334
models/user-create.ts
3435
models/user-response.ts
35-
models/validation-error-loc-inner.ts
3636
models/validation-error.ts
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.18.0-SNAPSHOT
1+
7.19.0

frontend/src/api/apis/authentication-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
1818
import globalAxios from 'axios';
1919
// Some imports not used depending on template conditions
2020
// @ts-ignore
21-
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
21+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
2222
// @ts-ignore
2323
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
2424
// @ts-ignore

frontend/src/api/apis/paper-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
1818
import globalAxios from 'axios';
1919
// Some imports not used depending on template conditions
2020
// @ts-ignore
21-
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
21+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
2222
// @ts-ignore
2323
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
2424
// @ts-ignore

frontend/src/api/apis/projects-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
1818
import globalAxios from 'axios';
1919
// Some imports not used depending on template conditions
2020
// @ts-ignore
21-
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
21+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
2222
// @ts-ignore
2323
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
2424
// @ts-ignore

frontend/src/api/apis/search-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
1818
import globalAxios from 'axios';
1919
// Some imports not used depending on template conditions
2020
// @ts-ignore
21-
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
21+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
2222
// @ts-ignore
2323
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
2424
// @ts-ignore

frontend/src/api/apis/users-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
1818
import globalAxios from 'axios';
1919
// Some imports not used depending on template conditions
2020
// @ts-ignore
21-
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
21+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
2222
// @ts-ignore
2323
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
2424
// @ts-ignore

frontend/src/api/common.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
6666
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
6767
if (parameter == null) return;
6868
if (typeof parameter === "object") {
69-
if (Array.isArray(parameter)) {
69+
if (Array.isArray(parameter) || parameter instanceof Set) {
7070
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
7171
}
7272
else {
@@ -91,13 +91,26 @@ export const setSearchParams = function (url: URL, ...objects: any[]) {
9191
url.search = searchParams.toString();
9292
}
9393

94+
/**
95+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
96+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
97+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
98+
*/
99+
export const replaceWithSerializableTypeIfNeeded = function(key: any, value: any) {
100+
if (value instanceof Set) {
101+
return Array.from(value);
102+
} else {
103+
return value;
104+
}
105+
}
106+
94107
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
95108
const nonString = typeof value !== 'string';
96109
const needsSerialization = nonString && configuration && configuration.isJsonMime
97110
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
98111
: nonString;
99112
return needsSerialization
100-
? JSON.stringify(value !== undefined ? value : {})
113+
? JSON.stringify(value !== undefined ? value : {}, replaceWithSerializableTypeIfNeeded)
101114
: (value || "");
102115
}
103116

0 commit comments

Comments
 (0)