summaryrefslogtreecommitdiff
path: root/scripts/test_uiuc_chat.py
diff options
context:
space:
mode:
authorblackhao <13851610112@163.com>2025-04-13 23:40:30 -0500
committerblackhao <13851610112@163.com>2025-04-13 23:40:30 -0500
commit5f26ab0f361e06e0a792c82436241883a11d80c5 (patch)
treebac7fd09a029586d261db989bef4b5c37e679f7e /scripts/test_uiuc_chat.py
parent864a62d1e97a7fbda50539e8bb6c92ffe82b3f31 (diff)
use gpt-4o
Diffstat (limited to 'scripts/test_uiuc_chat.py')
-rw-r--r--scripts/test_uiuc_chat.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/test_uiuc_chat.py b/scripts/test_uiuc_chat.py
new file mode 100644
index 0000000..c8c4e64
--- /dev/null
+++ b/scripts/test_uiuc_chat.py
@@ -0,0 +1,71 @@
+import requests
+
+API_URL = "https://uiuc.chat/api/chat-api/chat"
+API_KEY = "uc_0a6c6e31ac654737a3cd4d5c1ad4e4cd" # Replace with your actual key
+
+title = "Bias-Aware Agent: Enhancing Fairness in AI-Driven Knowledge Retrieval"
+abstract = "Advancements in retrieving accessible information have evolved more rapidly over the last few years... (omitting for brevity) ... by empowering users with transparency and awareness, this approach aims to foster more equitable information systems."
+'''
+headers = {
+ 'Content-Type': 'application/json'
+}
+messages = [
+ {
+ "role": "system",
+ # 可以空着,或写很简短
+ "content": "You are a helpful assistant."
+ },
+ {
+ "role": "user",
+ "content": (
+ "Here is a paper's title and abstract:\n\n"
+ f"Title: {title}\n\n"
+ f"Abstract: {abstract}\n\n"
+ "Respond with '1' (just the digit) if this paper is clearly about both "
+ "large language models (or generative text models) AND about bias/fairness. "
+ "Otherwise respond '0'. No explanation, no punctuation, only the digit."
+ )
+ }
+]
+
+data = {
+ "model": "llama3.1:8b-instruct-fp16",
+ "messages": messages,
+ "api_key": API_KEY,
+ "course_name": "llm-bias-papers",
+ "stream": False,
+ "temperature": 0.1
+}
+'''
+url = "https://uiuc.chat/api/chat-api/chat"
+headers = {
+ 'Content-Type': 'application/json'
+}
+data = {
+ "model": "llama3.1:8b-instruct-fp16",
+ "messages": [
+ {
+ "role": "system",
+ "content": "You are a helpful AI assistant. Follow instructions carefully."
+ },
+ {
+ "role": "user",
+ "content": "Here is a paper's title and abstract:\n\nTitle:" + title + "\n\nAbstract: " + abstract + "\n\nRespond with 'Yes' (just the word) if this paper is clearly about both large language models (or generative text models) AND about bias/fairness. Otherwise respond 'No'. No explanation, no punctuation, only the digit."
+ }
+ ],
+ "api_key": "uc_0a6c6e31ac654737a3cd4d5c1ad4e4cd",
+ "course_name": "llm-bias-papers",
+ "stream": False,
+ "temperature": 0.0,
+ "retrieval_only": False
+}
+
+response = requests.post(url, headers=headers, json=data)
+for chunk in response.iter_lines():
+ if chunk:
+ print(chunk.decode())
+resp = requests.post(API_URL, headers=headers, json=data)
+print("Status:", resp.status_code)
+print("Response:", resp.text)
+print("[DEBUG] resp.text =", resp.text)
+print("[DEBUG] resp.json() =", resp.json()) # if not raising error