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

Custom route.ts pointing to local gpt4free: shifted linenumbers -> suddenly added AI response? :-) #15

Open
macleod-be opened this issue Jan 18, 2024 · 4 comments

Comments

@macleod-be
Copy link

My setup in route.ts
...
// const response = await fetch("https://api.openai.com/v1/chat/completions", {
const response = await fetch("http://localhost:1337/v1/chat/completions", {
headers: {
"Content-Type": "application/json",
// Authorization: Bearer ${process.env.OPENAI_API_KEY},
},
...
Input File:
1
00:00:05,672 --> 00:00:07,674
Mr. Suero?

2
00:00:20,687 --> 00:00:22,272
Ah.

3
00:00:22,272 --> 00:00:25,275
Victor "Victory" Suero.

4
00:00:25,275 --> 00:00:26,777
Miles Sellars.

Output File:
1
00:00:05,672 --> 00:00:07,674
Certainly! Here is the translation to Dutch with the "

2
00:00:20,687 --> 00:00:22,272
" segment separator:

Meneer Suero?

3
00:00:22,272 --> 00:00:25,275
Ah.

4
00:00:25,275 --> 00:00:26,777
Victor "Victory" Suero.

Any Idea to fix this ?

@macleod-be
Copy link
Author

I have a change request.

Can you append a marker ex: ...
So 3 dots at the beginning of the ${text}.
When receiving the answer you know when the comments end and the translation begins.

The question to ask:
{
role: "user",
content: Translate this to ${language}. Including the 3 dots which marks the beginning of the translation. Interleave the "|" segment separator in the response.\n\n${text},
},

@yazinsai
Copy link
Owner

Certainly! Here is the translation to Dutch with the

That wasn't included in the examples I ran. Can you please confirm which model you're using? It's possible you can get away with just appending "ONLY include the translation in the response" to the prompt.

@macleod-be
Copy link
Author

"ONLY include the translation in the response": I already tested that as question to the AI.
They apparently want sometimes to say something :-).

Now I am not a full developper, I like to play around with someone code, like changing parameters.
It looks like the way your code is working:

  • you strip the timings
  • you ask to translate
  • each answer you get you append the timings you stripped

So you are not expecting a polite answer and clarification from the friendly AI :-)

  • that's why I suggested to included some kind of marker (###BOF###) like a begin of file, and explicity say to the AI that the specific line doesn't need a translation
  • The line after receiving the BOF back from the AI, you can start with you're time notations.

@macleod-be
Copy link
Author

I didn't changed anything else so I suppose you were looking for
model: "gpt-3.5-turbo",

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

2 participants