-
Notifications
You must be signed in to change notification settings - Fork 44.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(forge, agent): Resolve several issues for Chinese language & region #7200
fix(forge, agent): Resolve several issues for Chinese language & region #7200
Conversation
…F-8, solve cannot display chinese word 2、update the openai api key pattern, like sk-wa-xxx 3、add Optional for additional_input, in TaskRequestBody and StepRequestBody, to avoid 422 status in api
✅ Deploy Preview for auto-gpt-docs canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7200 +/- ##
===========================================
- Coverage 53.81% 33.77% -20.04%
===========================================
Files 124 18 -106
Lines 7021 1273 -5748
Branches 909 191 -718
===========================================
- Hits 3778 430 -3348
+ Misses 3110 815 -2295
+ Partials 133 28 -105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this PR! I wasn't aware of the issue with Chinese characters, luckily that's a straight-forward fix.
In addition to the comments below: the linting check fails at the moment, please fix the issues reported by the check.
response.headers["Content-Type"] = "application/json ; charset=UTF-8" | ||
return response | ||
|
||
app.middleware("http")(add_custom_header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.middleware
is intended to use as a decorator, like:
@app.middleware("http")
async def add_custom_header(request: Request, call_next: Callable) -> Response:
response = await call_next(request)
response.headers["Content-Type"] = "application/json; charset=utf-8"
return response
I cannot find any information about api keys with |
Just made a new key and the service keys for projects are sk-(whatever-service-account-name-is)-random-Blbk-random updated support in #7214 |
Maybe modifying the frontend is a better solution. From 5962f04a543a2cddd9a25dbe59f55191b4506420 Mon Sep 17 00:00:00 2001
From: Mirei124 <[email protected]>
Date: Tue, 23 Jul 2024 17:23:39 +0800
Subject: [PATCH] Fix Chinese garbled characters
---
frontend/lib/utils/rest_api_utility.dart | 6 +++---
frontend/lib/utils/uri_utility.dart | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frontend/lib/utils/rest_api_utility.dart b/frontend/lib/utils/rest_api_utility.dart
index ab83ddf..991db87 100644
--- a/frontend/lib/utils/rest_api_utility.dart
+++ b/frontend/lib/utils/rest_api_utility.dart
@@ -32,7 +32,7 @@ class RestApiUtility {
final effectiveBaseUrl = _getEffectiveBaseUrl(apiType);
final response = await http.get(Uri.parse('$effectiveBaseUrl/$endpoint'));
if (response.statusCode == 200) {
- return json.decode(response.body);
+ return json.decode(utf8.decode(response.bodyBytes));
} else {
throw Exception('Failed to load data');
}
@@ -48,7 +48,7 @@ class RestApiUtility {
headers: {"Content-Type": "application/json"},
);
if (response.statusCode == 200 || response.statusCode == 201) {
- return json.decode(response.body);
+ return json.decode(utf8.decode(response.bodyBytes));
} else {
// TODO: We are bubbling up the full response to show better errors on the UI.
// Let's put some thought into how we would like to structure this.
@@ -66,7 +66,7 @@ class RestApiUtility {
headers: {"Content-Type": "application/json"},
);
if (response.statusCode == 200 || response.statusCode == 201) {
- return json.decode(response.body);
+ return json.decode(utf8.decode(response.bodyBytes));
} else {
throw Exception('Failed to update data with PUT request');
}
diff --git a/frontend/lib/utils/uri_utility.dart b/frontend/lib/utils/uri_utility.dart
index ace65f0..5aebf10 100644
--- a/frontend/lib/utils/uri_utility.dart
+++ b/frontend/lib/utils/uri_utility.dart
@@ -69,7 +69,7 @@ class UriUtility {
return false;
}
- var data = json.decode(response.body);
+ var data = json.decode(utf8.decode(response.bodyBytes));
return data is Map && data['full_name'] == '$user/$repo';
}
}
--
2.45.2
|
@WangShaoyu1 Thank you for this change, we never managed to get it merged in dispite it being a great addition :( We are going to be removing the agent protocol server very soon in favour of the work going on in the rnd folder. If you are able to provide any help in making sure the rnd/autogpt_builder can support Chinese language we would really love the help! |
update:
1、add response header Content-Type:application/json,charest=UT…F-8, solve cannot display chinese word
2、update the openai api key pattern, like sk-wa-xxx
3、add Optional for additional_input, in TaskRequestBody and StepRequestBody, to avoid 422 status in api
Background
1、cannot show the Chinese word in the fluuter web subproject. Add response data header Content-Type:charset-UTF-8
2、I get a new openAI key,like sk-wa-xxxx, it can work in the chatgpt page ,but cannot be Verified in our project
3、In the flutter for web project,you enter the task in the chat Input, the api will return 422 status, because that the additional_input can not be null, so I add Optional in the file: forge/agent_protocol/models/task.py
PR Quality Scorecard ✨
+2 pts
+5 pts
+5 pts
+5 pts
-4 pts
+4 pts
+5 pts
-5 pts
agbenchmark
to verify that these changes do not regress performance?+10 pts