I have some reference materials on a website - a .txt file. Looks like I can have the API reference it, though I couldn’t find much documentation on it. The API doesn’t seem to like my request.
First of all, does the JSON look correct? If so, is the text file just included in the request and the chatbot can just see anything in there, as if it were a part of the user text? Would this be different than just including it in the main content parts ?
Here is the response I get:
{
"error": {
"code": 400,
"message": "* GenerateContentRequest.contents: contents is not specified\n",
"status": "INVALID_ARGUMENT"
}
}
The problem is that each part can be either a text part or a fileData part or inlineDataor one of the function parts. See https://ai.google.dev/api/rest/v1beta/Content#Part for details.
You’re allowed multiple parts - they just need to be different kinds in each. So that would look more like:
The second problem, however, is that although “text/plain” is probably a valid type (Vertex AI lists it as valid), you can’t import it from an external URL. The URL must be one that was provided when you uploaded the file using the File API.
When reading it in, it will treat it just like other parts in the prompt.
Wonderful - I think I tried it that way too but it also didn’t work. Perhaps it is related to your comment about needing to upload a file first. I haven’t tried that - I thought I could just reference my own URL links.
As for “reading it in and treating it like other parts in the prompt” - what would be the benefit, then? I already “pull in” text parts based on the user query as if it were an external file (that way i don’t always send up the entire reference doc). Is there a benefit to uploading a file vs. including it inside one of the text parts? Sure, a benefit would be that you don’t have to send it up every time but as I said, I already parse the user input so as to not load it if not necessary.
Is there a benefit such as not using as many tokens? Guess I’m just trying to figure out if my current solution is fine without having to also upload a file somewhere and then reference it.