Skip to content
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

input.method parameter is not used in getstream() #25

Open
Sheldenburg opened this issue Feb 29, 2024 · 2 comments
Open

input.method parameter is not used in getstream() #25

Sheldenburg opened this issue Feb 29, 2024 · 2 comments

Comments

@Sheldenburg
Copy link

Hi,
Thanks for creating this repo! Very useful for any react Chat interface.
I found the method parameter seems a bit redundant. In the example code, you have something like this below.

options: {
url: 'http://127.0.0.1:8000/chat',
method: 'POST',
headers:{
'Accept': 'application/json'
},
body: {
'query': 'Hello! how are you'
}
},
method: {
type: 'body',
key: 'query'
},
}

However, in the getStream function below, only the 'options' parameter is used.

export const getStream = async (input: string, options: UseChatStreamHttpOptions, method: UseChatStreamInputMethod) => {
options = mergeInputInOptions(input, options, method);

const params = '?' + new URLSearchParams(options.query).toString();

const response = await fetch(options.url + params, {
method: options.method,
headers: { ...DEFAULT_HEADERS, ...options.headers },
body: JSON.stringify(options.body, (_k, v) => v === null ? undefined : v)
});

if (!response.ok) throw new Error(response.statusText);

return response.body;
};

@niels-bosman
Copy link
Member

@Sheldenburg You can see we use options.method as the method. Does this not work for you?

@Sheldenburg
Copy link
Author

@Sheldenburg You can see we use options.method as the method. Does this not work for you?

Yes, it does. But in the type definition, you also have 'method' outside of options. This one has never got used.

options: {
url: 'http://127.0.0.1:8000/chat',
method: 'POST',
headers:{
'Accept': 'application/json'
},
body: {
'query': 'Hello! how are you'
}
},
method: {
type: 'body',
key: 'query'
},

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants