Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e92d6de
commit bc2d97b
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import requests | ||
import json | ||
import sys | ||
|
||
input = sys.argv[1] | ||
|
||
url = 'http://localhost:11434/api/generate' | ||
|
||
data = { | ||
"model": "llama2-chinese", | ||
"prompt": ''' | ||
Translate the following text to English, only return the content translated, no explaination: | ||
{} | ||
'''.format(input) | ||
} | ||
|
||
result = "" | ||
with requests.post(url, json=data, stream=True) as response: | ||
for line in response.iter_lines(): | ||
if line: | ||
json_response = json.loads(line) | ||
if not json_response["done"]: | ||
result += json_response["response"] | ||
|
||
print(result, flush=True) |