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

[AGE-119] Update deployment view to show endpoint for fetching the configuration #1572

Closed
mmabrouk opened this issue Apr 28, 2024 · 7 comments · Fixed by #1591
Closed

[AGE-119] Update deployment view to show endpoint for fetching the configuration #1572

mmabrouk opened this issue Apr 28, 2024 · 7 comments · Fixed by #1591
Assignees
Labels
enhancement New feature or request feature
Milestone

Comments

@mmabrouk
Copy link
Member

mmabrouk commented Apr 28, 2024

Context: Many users want to fetch the latest version of the configuration / prompt and use it in their code.

We want to update the deployment view to enable that.

The goal is to show in addition to the endpoint on how to call the LLM app hosted in agenta, provide an endpoint to get the configuration.

Todo:

  • Create mockup for the change in the deployment view
  • Implement the changes

From SyncLinear.com | AGE-119

@mmabrouk mmabrouk self-assigned this Apr 28, 2024
@dosubot dosubot bot added the enhancement New feature or request label Apr 28, 2024
@mmabrouk
Copy link
Member Author

Deployments view design

@bekossy I finished designing the view, let me know if there are any questions
@aybruhm Please check the comment inside the design. Should be straight forward.

@mmabrouk
Copy link
Member Author

@aybruhm This would require adding the logic to publish the first variant to the production environment per default. Could you please create an issue for that and add it to the sprint. Thank you!

@aybruhm
Copy link
Member

aybruhm commented Apr 29, 2024

@aybruhm This would require adding the logic to publish the first variant to the production environment per default. Could you please create an issue for that and add it to the sprint. Thank you!

Yup. Done.

@mmabrouk
Copy link
Member Author

Hi @bekossy
Please find below the code snippet that should be used for Python. Base id and environment should be dynamic

import agenta
import os


agenta.get_config(base_id={},
                  environment={},
                  cache_timeout=None)

@mmabrouk
Copy link
Member Author

mmabrouk commented May 1, 2024

@mmabrouk provide the other js and curl and code

@mmabrouk
Copy link
Member Author

mmabrouk commented May 1, 2024

@bekossy I finalized the implementation for the prompt fetching endpoint. Please find the snippets below:

# os.environ["AGENTA_API_KEY"] = "your_api_key" # Only when using cloud
# os.environ["HOST"] = "https://cloud.agenta.ai"  
from agenta import Agenta
 ag = Agenta()
 ag.get_config(base_id={}, environment={}, cache_timeout=600) # timeout 300 per default

The js snippet

import axios from 'axios';

const getConfig = async (baseId, environmentName = null) => {
   try {
       const baseUrl = 'https://cloud.agenta.ai/api';
       const params = {
           base_id: baseId,
           environment_name: environmentName
       };

       const response = await axios.get(`${baseUrl}/configs`, {
           params: params,
           headers: {
               'Authorization': `Bearer YOUR_API_KEY`, 
               'Content-Type': 'application/json'
           },
           timeout: 60000
       });

       if (response.status >= 200 && response.status < 300) {
           return response.data;
       } else if (response.status === 422) {
           throw new Error(`Unprocessable Entity: ${JSON.stringify(response.data)}`);
       }
   } catch (error) {
       if (error.response) {
           console.error(`API Error: ${error.response.status}`, error.response.data);
       } else if (error.request) {
           console.error('API Error: No response received', error.request);
       } else {
           console.error('Error', error.message);
       }
       throw error;
   }
};

getConfig('{base_id}', '{environment_name}').then(console.log).catch(console.error);

The curl snippet

curl -X GET "https://cloud.agenta.ai/api/configs?base_id={base_id}&environment_name={environment_name}" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    --connect-timeout 60

@bekossy
Copy link
Member

bekossy commented May 2, 2024

Fixed in #1591

@bekossy bekossy closed this as completed May 2, 2024
@mmabrouk mmabrouk added this to the v.44 milestone May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants