forked from Jometeorie/KnowledgeSpread
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_gpt4.py
36 lines (30 loc) · 1 KB
/
set_gpt4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import torch
import json
import os
import numpy as np
import random
import requests
def assess_credibility(history, generated_text):
api_key = ""
conversation_history = f"\nFull History:\n"
for i, h in enumerate(history):
name = h["name"]
text = h["text"]
conversation_history += f"\t{i+1}. {name}: {text}\n"
conversation_history += f"\nCurrent Response:\n{generated_text}\n"
url = ""
headers = {
'Authorization': f'Bearer {api_key}', # Replace {api_key} with your actual API key
'Content-Type': 'application/json'
}
request = {
"inputs": {},
"query": conversation_history,
"response_mode": "blocking",
"conversation_id": "", # Set the conversation ID if necessary
"user": "abc-123",
}
response = requests.post(url, headers=headers, json=request)
response_data = response.json()
answer = response_data.get('answer', None)
return answer