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

google ai models. #5337

Open
0wwafa opened this issue Aug 30, 2024 · 5 comments
Open

google ai models. #5337

0wwafa opened this issue Aug 30, 2024 · 5 comments
Assignees
Labels
planned planned feature, will support in the future

Comments

@0wwafa
Copy link

0wwafa commented Aug 30, 2024

Instead of having them fixed, get them dynamycally:

            // Thanks to Zibri for this routine.

            async function getPreferredModel(apiKey) {
                try {
                    const response = await fetch('https://generativelanguage.googleapis.com/v1beta/models', {
                        headers: {
                        	  'content-type': 'application/json; charset=UTF-8',
                            'x-goog-api-key': apiKey,
                        },
                    });

                    if (!response.ok) {
                        throw new Error(`Failed to fetch models: ${response.status} ${response.statusText}`);
                    }

                    const data = await response.json();
                    const modelNames = data.models.map(model => model.name.split('/')[1]);

                    // 1. Find last "pro" and "exp" model
                    let latestModel = modelNames.filter(name => name.includes("pro") && name.includes("exp")).pop();

                    // 2. If not found, find the last "pro" model
                    if (!latestModel) {
                        latestModel = modelNames.filter(name => name.includes("pro")).pop();
                    }

                    return [latestModel, modelNames];

                } catch (error) {
                    console.error(`Error fetching and processing model names:`, error);
                    return null;
                    // Return null if no matching model or error
                }
            }

This returns the latest pro-exp model AND the full list of models.

["gemini-1.5-pro-exp-0827",["chat-bison-001","text-bison-001","embedding-gecko-001","gemini-1.0-pro-latest","gemini-1.0-pro","gemini-pro","gemini-1.0-pro-001","gemini-1.0-pro-vision-latest","gemini-pro-vision","gemini-1.5-pro-latest","gemini-1.5-pro-001","gemini-1.5-pro","gemini-1.5-pro-exp-0801","gemini-1.5-pro-exp-0827","gemini-1.5-flash-latest","gemini-1.5-flash-001","gemini-1.5-flash-001-tuning","gemini-1.5-flash","gemini-1.5-flash-exp-0827","gemini-1.5-flash-8b-exp-0827","embedding-001","text-embedding-004","aqa"]]

@nextchat-manager
Copy link

Please follow the issue template to update title and description of your issue.

@0wwafa
Copy link
Author

0wwafa commented Aug 30, 2024

Also, please add:

HARM_CATEGORY_CIVIC_INTEGRITY

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Also, please add:

HARM_CATEGORY_CIVIC_INTEGRITY

@0wwafa
Copy link
Author

0wwafa commented Aug 30, 2024

Bot detected the issue body's language is not English, translate it automatically.

Also, please add:

HARM_CATEGORY_CIVIC_INTEGRITY

by the way, where, in settings do I set the harm category?

@0wwafa
Copy link
Author

0wwafa commented Aug 30, 2024

also: in the fetch request use:

                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                            'Cache-Control': 'no-store',
                            'x-goog-api-key': apiKey
                        },

and remove key= from the query.

@lloydzhou lloydzhou added the planned planned feature, will support in the future label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planned planned feature, will support in the future
Projects
None yet
Development

No branches or pull requests

4 participants