Tinkabellaa commited on
Commit
20c430a
·
verified ·
1 Parent(s): 5f34889

Create Output.txt

Browse files
Files changed (1) hide show
  1. Output.txt +29 -0
Output.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration for generating 3000 words using OpenAI API
2
+
3
+ import openai
4
+
5
+ # Estimate: 1 word ≈ 1.3 tokens, so 3000 words ≈ 3900 tokens
6
+ # max_tokens is the *maximum* the model can return in tokens
7
+ # GPT-4-turbo currently allows up to 4096 tokens in one response (or 128k in some versions)
8
+
9
+ config = {
10
+ "model": "gpt-4",
11
+ "temperature": 0.7,
12
+ "max_tokens": 3900, # aiming for ~3000 words (3900 tokens ≈ 3000 words)
13
+ "top_p": 1,
14
+ "frequency_penalty": 0,
15
+ "presence_penalty": 0,
16
+ "stop": None
17
+ }
18
+
19
+ prompt = "Write a detailed story about a lone warrior in a post-apocalyptic world who discovers a hidden underground city. The story should be around 3000 words long."
20
+
21
+ response = openai.ChatCompletion.create(
22
+ messages=[
23
+ {"role": "system", "content": "You are a helpful, descriptive storyteller."},
24
+ {"role": "user", "content": prompt}
25
+ ],
26
+ **config
27
+ )
28
+
29
+ print(response["choices"][0]["message"]["content"])