This repository contains a Flask application that connects with the Anthropic API and retrieves data from the OpenAlex API. The goal is to receive queries on an endpoint, search for data on the OpenAlex API, and return the retrieved works.
-
Clone the repository:
git clone https://github.com/githubnext/workspace-blank.git cd workspace-blank -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install the dependencies:
pip install -r requirements.txt
-
Set up the Anthropic API key:
- Anthropic: Sign up on Anthropic and get your API key.
-
Create a
.envfile in the root directory and add your API key:ANTHROPIC_API_KEY=your_anthropic_api_key
-
Run the Flask application:
flask run
-
Send a GET request to the
/queryendpoint with the query as a parameter:curl -X GET "http://127.0.0.1:5000/query?question=your_query_here" -
The Flask application will call the OpenAlex API to retrieve data based on the query.
-
The retrieved data will be returned as a JSON response:
{ "works": [ { "doi": "10.1234/example", "title": "Example Title", "abstract": "This is an example abstract.", "pub_year": 2021 }, ... ] }
Here is an example of how to use the Flask application:
-
Start the Flask application:
flask run
-
Send a GET request to the
/queryendpoint:curl -X GET "http://127.0.0.1:5000/query?question=What+is+the+impact+of+climate+change+on+marine+life?" -
You will receive a JSON response with the retrieved works:
{ "works": [ { "doi": "10.1234/example", "title": "Impact of Climate Change on Marine Life", "abstract": "This study explores the effects of climate change on marine ecosystems.", "pub_year": 2021 }, ... ] }
- Make sure to replace
your_anthropic_api_keywith your actual API key in the.envfile. - You can customize the OpenAlex API calls and the Anthropic prompts as needed.