Myaptla commited on
Commit
b72d25f
1 Parent(s): 42b9643

Update webapi_claude.py

Browse files
Files changed (1) hide show
  1. webapi_claude.py +6 -15
webapi_claude.py CHANGED
@@ -2,7 +2,6 @@ from flask import Flask, request, jsonify
2
  import asyncio
3
  import aiohttp, os
4
 
5
-
6
  app = Flask(__name__)
7
 
8
  async def claude_new_process(prompt):
@@ -13,22 +12,14 @@ async def claude_new_process(prompt):
13
  data = {
14
  "prompt": prompt,
15
  "model": "claude-v1.3-100k",
16
- "max_tokens_to_sample": 1000000, #tokens (any number for the free API)
17
- "temperature": "0.52", #you know what this is
18
- "stopsequences": "\n\nHuman: ", #(don't touch)
19
  }
20
 
21
- #proxy_url = "8.219.97.248"
22
- #proxy_port = "80"
23
- #proxy = f'http://{proxy_url}:{proxy_port}'
24
-
25
  async with aiohttp.ClientSession() as session:
26
- async with session.post("https://api.anthropic.com/v1/complete", json=data, headers=headers
27
- #, proxy=proxy
28
- ) as response:
29
-
30
  if response.status == 200:
31
- #print(response.status, await response.json())
32
  return 200, await response.json()
33
  else:
34
  return response.status, "error"
@@ -53,8 +44,8 @@ def api_claude_new_process():
53
 
54
  async def test():
55
  status, response = await claude_new_process('\n\nHuman: Hello! \n\nGigachad: ')
56
- print (response['completion'])
57
 
58
  if __name__ == '__main__':
59
  #asyncio.run(test())
60
- app.run(debug=True, port='7860', host='0.0.0.0')
 
2
  import asyncio
3
  import aiohttp, os
4
 
 
5
  app = Flask(__name__)
6
 
7
  async def claude_new_process(prompt):
 
12
  data = {
13
  "prompt": prompt,
14
  "model": "claude-v1.3-100k",
15
+ "max_tokens_to_sample": 1000000,
16
+ "temperature": 0.52,
17
+ "stopsequences": "\n\nHuman: ",
18
  }
19
 
 
 
 
 
20
  async with aiohttp.ClientSession() as session:
21
+ async with session.post("https://api.anthropic.com/v1/complete", json=data, headers=headers) as response:
 
 
 
22
  if response.status == 200:
 
23
  return 200, await response.json()
24
  else:
25
  return response.status, "error"
 
44
 
45
  async def test():
46
  status, response = await claude_new_process('\n\nHuman: Hello! \n\nGigachad: ')
47
+ print(response['completion'])
48
 
49
  if __name__ == '__main__':
50
  #asyncio.run(test())
51
+ app.run(debug=True, port=7860, host='0.0.0.0')