aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/gpt/GPT.ts
diff options
context:
space:
mode:
authoreleanor-park <eleanor_park@brown.edu>2024-07-23 12:10:03 -0400
committereleanor-park <eleanor_park@brown.edu>2024-07-23 12:10:03 -0400
commit9e2f51dc5a1c82e9293e04c71f4430fd67ff3378 (patch)
treeb9111a1e31a31223c556850330ec187f3c396d64 /src/client/apis/gpt/GPT.ts
parent3e1ef3d0b5445065ab3f44ffc17bbb04efaa8c8a (diff)
parenta1960941edc43d71508ec5cb244f453eb06cf2e1 (diff)
Merge remote-tracking branch 'origin/zach-starter' into eleanor-gptdraw
Diffstat (limited to 'src/client/apis/gpt/GPT.ts')
-rw-r--r--src/client/apis/gpt/GPT.ts32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts
index a7bd05a21..cbe2f0582 100644
--- a/src/client/apis/gpt/GPT.ts
+++ b/src/client/apis/gpt/GPT.ts
@@ -156,5 +156,35 @@ const gptImageLabel = async (src: string): Promise<string> => {
return 'Error connecting with API';
}
};
+const gptHandwriting = async (src: string): Promise<string> => {
+ try {
+ const response = await openai.chat.completions.create({
+ model: 'gpt-4o',
+ temperature: 0,
+ messages: [
+ {
+ role: 'user',
+ content: [
+ { type: 'text', text: 'What is this does this handwriting say. Only return the text' },
+ {
+ type: 'image_url',
+ image_url: {
+ url: `${src}`,
+ detail: 'low',
+ },
+ },
+ ],
+ },
+ ],
+ });
+ if (response.choices[0].message.content) {
+ return response.choices[0].message.content;
+ }
+ return 'Missing labels';
+ } catch (err) {
+ console.log(err);
+ return 'Error connecting with API';
+ }
+};
-export { gptAPICall, gptImageCall, GPTCallType, gptImageLabel, gptGetEmbedding };
+export { gptAPICall, gptImageCall, GPTCallType, gptImageLabel, gptGetEmbedding, gptHandwriting };