You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to customize typechat for my own model and personalized scenarios (exp. for Chinese users)? #86
I am currently deploying the model and exposing a callable OpenAI API. I am modifying model.ts to fit my own model, but I'm experiencing instability when using mpt-30b-chat and mpt-30b-instruct. Math functions are frequently being called incorrectly. JSON templates often fail to validate in complex projects. Do you have any suggestions, such as adding a system prompt or modifying the template to accommodate Chinese?
I'll just note that TypeChat has a bring-your-own-model approach. You don't need to fork the library, you just need to provide an object with a complete method.
Hi! I've completed the first level of the experiment, which involved making additional translation requests based on the returned results. It seems that we need to obtain its output before we can begin the transformation. I have tried adding new requirements for translation in the createRequestPrompt method in typechat, but I have attempted multiple prompts to construct a structured processing flow, even with GPT-4, but have not been successful. So, in order to ensure a good result, here are a few suggestions:
Before executing typechat, you can translate your schema file (using GPT or other simple translation services), where all string types are translated into Chinese. I have tried this, and if the content of your schema is in Chinese or another language, the values in the output JSON data will be translated accordingly.
After executing typechat, you can perform translation on the resulting output. I achieved this using a simple prompt.
Prompt
--
constprompt=`${JSON.stringify(cart,undefined,2)}\n above is json string all of the following JSON key and value, the values of string need to translate into Chinese, but the JSON key name not change, such like "items": [ { "type": "lineitem", "product": { "type": "LatteDrinks", "name": "latte" }, "quantity": 1 } ] will translate to chinese: [{ "type": "行项目", "product": { "type": "拿铁饮料", "name": "拿铁" }, "quantity": 1 }] and keep JSON data structure`;
This way, you can always translate the current output, reducing the amount of translation needed. However, please note that translating the data may not preserve the same types as defined in the schema file. Therefore, this method is more suitable for displaying text data rather than precise data.
Another approach, which I haven't achieved yet, is to granularly parse each JSON key and value within typechat and handle the required actions. This method should also be feasible but requires more experimentation time. For example, in my project, there is a section for translating Markdown. A one-shot experiment similar to this prompt can be found in this https://github.com/weykon/translate-md-by-gpt/blob/main/pmt_set.ts . (the original code is quite long, so please check the link for details.)
Using this method of enabling translation options may result in two completely different sets of prompts, which increases complexity.
I believe a better approach would be to use the i18n (internationalization) concept and create multiple language schema files, such as schema.en.ts, schema.zh.ts, schema.it.ts, to obtain more accurate outputs.
So, currently, I think the fourth method is a better choice.
Related discussion:feat: export createAxiosLanguageModel #94 requested custom HTTP-client configuration, including proxies. The current implementation uses native fetch, rather than exposing Axios internals.
createLanguageModel(process.env) now honors HTTPS_PROXY, HTTP_PROXY, and ALL_PROXY (including lowercase variants), along with NO_PROXY. Install the optional proxy dependency with npm install undici, then configure your actual proxy, for example:
HTTPS_PROXY=http://127.0.0.1:7890
When calling createOpenAILanguageModel or createAzureOpenAILanguageModel directly, pass { proxyUrl } through the options argument instead; the setup documentation has the signatures.
This addresses proxy routing, not the original questions about MPT output quality or Chinese-language prompting. A VPN or proxy can still have separate connectivity problems.
Hi! I've completed the first level of the experiment, which involved making additional translation requests based on the returned results. It seems that we need to obtain its output before we can begin the transformation. I have tried adding new requirements for translation in the createRequestPrompt method in typechat, but I have attempted multiple prompts to construct a structured processing flow, even with GPT-4, but have not been successful. So, in order to ensure a good result, here are a few suggestions:
Before executing typechat, you can translate your schema file (using GPT or other simple translation services), where all string types are translated into Chinese. I have tried this, and if the content of your schema is in Chinese or another language, the values in the output JSON data will be translated accordingly.
After executing typechat, you can perform translation on the resulting output. I achieved this using a simple prompt.
Prompt
const prompt =${JSON.stringify(cart, undefined, 2)}\n above is json string all of the following JSON key and value, the values of string need to translate into Chinese, but the JSON key name not change, such like "items": [ { "type": "lineitem", "product": { "type": "LatteDrinks", "name": "latte" }, "quantity": 1 } ] will translate to chinese: [{ "type": "行项目", "product": { "type": "拿铁饮料", "name": "拿铁" }, "quantity": 1 }] and keep JSON data structure;
This way, you can always translate the current output, reducing the amount of translation needed. However, please note that translating the data may not preserve the same types as defined in the schema file. Therefore, this method is more suitable for displaying text data rather than precise data.
Another approach, which I haven't achieved yet, is to granularly parse each JSON key and value within typechat and handle the required actions. This method should also be feasible but requires more experimentation time. For example, in my project, there is a section for translating Markdown. A one-shot experiment similar to this prompt can be found in this https://github.com/weykon/translate-md-by-gpt/blob/main/pmt_set.ts . (the original code is quite long, so please check the link for details.)
Using this method of enabling translation options may result in two completely different sets of prompts, which increases complexity.
I believe a better approach would be to use the i18n (internationalization) concept and create multiple language schema files, such as schema.en.ts, schema.zh.ts, schema.it.ts, to obtain more accurate outputs.
So, currently, I think the fourth method is a better choice.
Activity
DanielRosenwasser commentedon Aug 3, 2023
I'll just note that TypeChat has a bring-your-own-model approach. You don't need to fork the library, you just need to provide an object with a
completemethod.Here's an example
About other languages like Chinese - I'm not so sure. Maybe others have tips and ideas?
weykon commentedon Aug 4, 2023
Hi! I've completed the first level of the experiment, which involved making additional translation requests based on the returned results. It seems that we need to obtain its output before we can begin the transformation. I have tried adding new requirements for translation in the
createRequestPromptmethod intypechat, but I have attempted multiple prompts to construct a structured processing flow, even with GPT-4, but have not been successful. So, in order to ensure a good result, here are a few suggestions:Before executing
typechat, you can translate your schema file (using GPT or other simple translation services), where all string types are translated into Chinese. I have tried this, and if the content of your schema is in Chinese or another language, the values in the output JSON data will be translated accordingly.After executing
typechat, you can perform translation on the resulting output. I achieved this using a simple prompt.Prompt
--This way, you can always translate the current output, reducing the amount of translation needed. However, please note that translating the data may not preserve the same types as defined in the schema file. Therefore, this method is more suitable for displaying text data rather than precise data.
typechatand handle the required actions. This method should also be feasible but requires more experimentation time. For example, in my project, there is a section for translating Markdown. Aone-shotexperiment similar to this prompt can be found in this https://github.com/weykon/translate-md-by-gpt/blob/main/pmt_set.ts . (the original code is quite long, so please check the link for details.)Using this method of enabling translation options may result in two completely different sets of prompts, which increases complexity.
schema.en.ts,schema.zh.ts,schema.it.ts, to obtain more accurate outputs.So, currently, I think the fourth method is a better choice.
ybsun0215 commentedon Sep 1, 2023
Hello, have you encountered an error after mounting vpn? How was it resolved?
robgruen commentedon Oct 15, 2026
Following up on cody (@ybsun0215)'s VPN/proxy question in this thread: built-in HTTP(S) proxy support was added in #382, merged on July 7, 2026.
References:
fetch, rather than exposing Axios internals.createLanguageModel(process.env)now honorsHTTPS_PROXY,HTTP_PROXY, andALL_PROXY(including lowercase variants), along withNO_PROXY. Install the optional proxy dependency withnpm install undici, then configure your actual proxy, for example:HTTPS_PROXY=http://127.0.0.1:7890When calling
createOpenAILanguageModelorcreateAzureOpenAILanguageModeldirectly, pass{ proxyUrl }through the options argument instead; the setup documentation has the signatures.This addresses proxy routing, not the original questions about MPT output quality or Chinese-language prompting. A VPN or proxy can still have separate connectivity problems.
robgruen commentedon Oct 15, 2026
Please see my response for #142