Skip to content

Commit

Permalink
update g4f provider
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLJX committed Dec 29, 2023
1 parent 57be475 commit 4125267
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
54 changes: 52 additions & 2 deletions requestgpt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
# translation.py
import requests
import json
import g4f

def get_gpt_translation(input, length="medium", timeout=7):
url = "https://free.churchless.tech/v1/chat/completions"
headers = {"Content-Type": "application/json"}
print(g4f.Provider.Ails.params) # supported args

# Automatic selection of provider

# streamed completion
response = g4f.ChatCompletion.create(
model="gpt-3.5-turbo",
provider=g4f.Provider.You,
messages=[{
"role": "user",
"content": "translate the following to English:\"さっきからこいつの思考が全く読めない\" \n Reply with only the translation, followed by a full in depth explanation starting with \"Full explanation:\"."
},
{
"role": "assistant",
"content": """I haven't been able to read this person's thoughts at all since a while ago. \nFull explanation:
1. さっきから (sakki kara): "since a while ago" or "for some time now"
2. こいつ (koitsu): "this guy" or "this person" (informal and somewhat rude)
3. の (no): possessive particle, similar to "'s" or "of" in English
4. 思考 (shikō): "thought" or "thinking"
5. が (ga): subject particle
6. 全く (mattaku): "completely" or "entirely"
7. 読めない (yomenai): negative potential form of the verb 読む (yomu, "to read"), meaning "can't read"
The speaker is expressing their inability to understand or predict what the other person is thinking."""
},
{
"role": "user",
"content": "translate the following to English:\"これは僕が己の過ちに対して支払った代償であり\" \n Reply with only the translation, followed by a full in depth explanation starting with \"Full explanation:\"."
},
{
"role": "assistant",
"content": """This is the price I paid for my own mistakes. \nFull explanation:
1. これは (Kore wa): This means "this is" and is used to refer to something that has been mentioned or is being discussed.
2. 僕が (boku ga): "僕" (boku) is a first-person pronoun meaning "I" or "me," and "が" (ga) is a subject marker. Together, they mean "I" as the subject of the sentence.
3. 己の過ちに対して (onore no ayamachi ni taishite): "己" (onore) is a pronoun meaning "oneself" or "myself." "過ち" (ayamachi) means "mistake" or "error." "に対して" (ni taishite) is a preposition meaning "toward" or "in relation to." So, this phrase means "toward my own mistakes."
4. 支払った代償であり (shiharatta daishou de ari): "支払った" (shiharatta) is the past tense of the verb "支払う" (shiharau), which means "to pay" or "to compensate." "代償" (daishou) means "price" or "compensation." "であり" (de ari) is a formal way to say "is" or "to be." This phrase means "the price I paid."
The speaker is acknowledging that the situation they are facing is a consequence or payment they have to bear for their own errors or wrongdoings. It suggests a sense of personal accountability and responsibility for the negative outcome they are experiencing."""
},
{
"role": "user",
"content": "translate the following to English:\"" + input + "\" \n Reply with only the translation, followed by a full in depth explanation starting with \"Full explanation:\"."
}],
# stream=True,
)

print(response)
return response
# url = "https://free.churchless.tech/v1/chat/completions"
# url = "https://purgpt.xyz/v1/chat/completions"
url = "https://api.openai.com/v1/chat/completions"
headers = {"Content-Type": "application/json",
}
payload_short = {
"messages": [
{
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ PySoundFile==0.9.0.post1
Requests==2.30.0
soundfile==0.12.1
TTS==0.13.3
g4f
httpx

0 comments on commit 4125267

Please sign in to comment.