Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openai: ^4.24.7 | possible upgrade #2

Open
serbyxp opened this issue Feb 2, 2024 · 0 comments
Open

openai: ^4.24.7 | possible upgrade #2

serbyxp opened this issue Feb 2, 2024 · 0 comments

Comments

@serbyxp
Copy link

serbyxp commented Feb 2, 2024

Not so much an issue and I'm not developing qwik-docs-es. I was looking through this to find a way to use openai in qwik, I noticed this version is pre openai 4.0 ( which got revamped SDK ), not sure if you even care about updating it to use the new SDK methods. which would just change the custom fetch methods

embedding:
ref: https://platform.openai.com/docs/api-reference/embeddings/create
__
https://github.com/BuilderIO/qwik-docs-es/blob/main/src/components/qwik-gpt/search.tsx#L11

_
chat completions :
ref: https://platform.openai.com/docs/api-reference/streaming
__
https://github.com/BuilderIO/qwik-docs-es/blob/main/src/components/qwik-gpt/search.tsx#L77-L95

https://github.com/BuilderIO/qwik-docs-es/blob/main/src/components/qwik-gpt/streaming-gpt.ts#L1-L19
_

Don't have to refactor anything its basically the same and could just continue to use the fetch that you have and all that would need is to changed is the type in:
https://github.com/BuilderIO/qwik-docs-es/blob/main/src/components/qwik-gpt/streaming-gpt.ts#L1-L19

possible upgrade ( unless I missed another type somewhere ), if not the qwik-gpt/search.tsx throws a namespace type error,
By just modifying it to this :


import type OpenAI from "openai";


export async function* chatCompletion(apiKey: string, request: OpenAI.Chat.ChatCompletionCreateParams) {...

v4.0+ the request types change
ref:
https://github.com/openai/openai-node?tab=readme-ov-file#request--response-types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant