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

feat(api): integrate external apps with nesis #88

Merged
merged 15 commits into from
May 24, 2024

Conversation

mawandm
Copy link
Contributor

@mawandm mawandm commented May 22, 2024

We introduce integrating external apps with Nesis by providing the apps API, which allows for adding an app and authenticating with an app secret.

Part of #83

@mawandm
Copy link
Contributor Author

mawandm commented May 23, 2024

Tested with

  1. Create an Admin user session with
    NESIS_TOKEN=$(curl -s -X POST -H "Content-Type: application/json"  -k http://localhost:6000/v1/sessions -d 
    '{"email":"test.user@domain.com","password":"password"}' | jq -r '.token')
    
  2. Create a datasource with
    curl -d '{"type": "s3", "name": "ht-documents", "connection": {"user": "your_username","password":"your_password","endpoint": "http://localhost:4566","dataobjects": "documents","region": "us-east-1"}}' -H "Content-Type: application/json"  -H "Authorization: Bearer $NESIS_TOKEN" -X POST http://127.0.0.1:6000/v1/datasources`
    
  3. Post a document to the RAG engine with
    curl -X POST -H "Content-Type: multipart/form-data; boundary=----------------------------4ebf00fbcf09" --form "file=@Downloads/reseller-agreement.docx" --form 'metadata={"file_name":"Downloads/reseller-agreement.docx","datasource": "ht-documents"}' http://localhost:8080/v1/ingest/files
    
  4. Create a role with
    curl -X POST --url http://localhost:6000/v1/roles -H "Content-Type: application/json" -H "Authorization: Bearer $NESIS_TOKEN" --data '{"name":"document-manager","policy":{"items":[{"action":"read","resource":"datasources/*"},{"action":"create","resource":"predictions/*"}]}}'
    
  5. Attach the role to another user (previously created) with
    curl -X POST --url http://localhost:6000/v1/users/<user-id>/roles -H "Content-Type: application/json" -H "Authorization: Bearer $NESIS_TOKEN" --data '{"id":"<role-id>"}'`
    
  6. Create an app with
    NESIS_APP_TOKEN=$(curl -X POST --url http://localhost:6000/v1/apps -H "Content-Type: application/json" -H "Authorization: Bearer $NESIS_TOKEN" --data '{"name":"test-app"}' | jq -r '.token')
    
  7. Create a prediction as the app with (without the X-Nesis-Request-UserKey fails due to permissions)
    curl -X POST http://localhost:6000/v1/modules/qanda/predictions --header "Content-Type: application/json"  -H "Authorization: Bearer $NESIS_APP_TOKEN" --data '{"query": "Summarise only office agreement"}'
    
  8. Create the prediction as the user with
    curl -X POST http://localhost:6000/v1/modules/qanda/predictions --header "Content-Type: application/json"  -H "Authorization: Bearer $NESIS_APP_TOKEN" -H "X-Nesis-Request-UserKey: <user-id>" --data '{"query": "Summarise only office agreement"}'
    

@mawandm mawandm marked this pull request as ready for review May 24, 2024 00:50
@mawandm mawandm merged commit f912646 into main May 24, 2024
6 checks passed
@mawandm mawandm deleted the 83-manage-apps-with-nesis branch May 24, 2024 00:53
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

Successfully merging this pull request may close these issues.

1 participant