-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversion issue in createOpenAPIChain
?
#3266
Comments
🤖 Hello again, @Manouchehri! Good to see you back. I see you've run into a new issue with the |
🤖 Based on the error message you provided, it seems like the issue is with the function name 'api_v1_0.0/weather_get' not matching the expected pattern '^[a-zA-Z0-9-]{1,64}$'. This pattern does not allow for periods ('.') in the function name, which is why the error is being thrown. The Unfortunately, the To further investigate this issue, it would be helpful if you could provide the OpenAPI specification that you're using. This would allow us to see if the issue is with the specification itself or with how the Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
@dosubot The OpenAPI spec is: {"openapi":"3.0.0","info":{"version":"1.0.0","title":"Cayman Weather API (unofficial)"},"tags":[{"name":"language","description":"en"}],"components":{"schemas":{},"parameters":{}},"paths":{"/api/v1.0.0/weather":{"get":{"operationid":"get_weather","responses":{"200":{"description":"Fetch weather data from the Cayman Weather site.","content":{"application/json":{"schema":{"type":"object","properties":{}}}}},"404":{"description":"Unable to fetch the weather data","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"500":{"description":"Unexpected internal server error.","content":{"application/json":{"schema":{"type":"object","properties":{"status_code":{"type":"number","description":"Original error code.","example":504},"message":{"type":"string"}}}}}}}}}}} |
🤖 The error message you're seeing is due to the function name 'api_v1_0.0/weather_get' not matching the expected pattern '^[a-zA-Z0-9-]{1,64}$'. This pattern indicates that function names should only contain alphanumeric characters, underscores, and dashes, and should be between 1 and 64 characters in length. The issue seems to be with the version number in your OpenAPI specification's path ('/api/v1.0.0/weather'). The 'createOpenAPIChain' function in langchainjs is likely converting this path into a function name, replacing '/' with '', but it's not replacing '.' with '', which is causing the error. To resolve this issue, you could try changing the version number in your OpenAPI specification's path to not include periods, for example '/api/v1_0_0/weather'. This should result in a function name that matches the expected pattern. However, this is just a workaround, and it might not be ideal if you have a lot of paths with version numbers in them. A more robust solution would be to modify the 'createOpenAPIChain' function in langchainjs to also replace '.' with '_' when converting paths into function names. Unfortunately, as a technical support rep, I don't have the ability to make this change myself, but I would recommend reaching out to the maintainers of langchainjs to suggest this improvement. In the meantime, you could also consider creating a custom function to preprocess your OpenAPI specification and replace '.' with '_' in the paths before passing it to 'createOpenAPIChain'. Here's a simple example of how you could do this: function preprocessOpenAPISpec(spec) {
for (let path in spec.paths) {
let newPath = path.replace(/\./g, '_');
if (newPath !== path) {
spec.paths[newPath] = spec.paths[path];
delete spec.paths[path];
}
}
return spec;
}
const spec = await fetch('https://caymanweather.aimoda.dev/openapi.json').then(res => res.json());
const preprocessedSpec = preprocessOpenAPISpec(spec);
const chain = await createOpenAPIChain(preprocessedSpec, {
llm: model
});
const result = await chainapi.run(`What's the current weather in Cayman?`); I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
* Use replaceAll instead of replace when generating operationid. Fixes #3266. * Format code.
Looks like there's an unexpected
.
in the API function name somehow, can't trace down where the.
->_
replacement is supposed to be happening in langchainjs.Code to reproduce:
The text was updated successfully, but these errors were encountered: