phind_test.py 962 B

12345678910111213141516171819202122232425262728
  1. import phind
  2. prompt = 'hello world'
  3. # normal completion
  4. result = phind.Completion.create(
  5. model = 'gpt-4',
  6. prompt = prompt,
  7. results = phind.Search.create(prompt, actualSearch = False), # create search (set actualSearch to False to disable internet)
  8. creative = False,
  9. detailed = False,
  10. codeContext = '') # up to 3000 chars of code
  11. print(result.completion.choices[0].text)
  12. prompt = 'who won the quatar world cup'
  13. # help needed: not getting newlines from the stream, please submit a PR if you know how to fix this
  14. # stream completion
  15. for result in phind.StreamingCompletion.create(
  16. model = 'gpt-3.5',
  17. prompt = prompt,
  18. results = phind.Search.create(prompt, actualSearch = True), # create search (set actualSearch to False to disable internet)
  19. creative = False,
  20. detailed = False,
  21. codeContext = ''): # up to 3000 chars of code
  22. print(result.completion.choices[0].text, end='', flush=True)
粤ICP备19079148号