Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffzwang authored Jul 21, 2023
1 parent 1ba6527 commit 035bf4d
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,62 @@
# Metaphor Python

An ergonomic way to use Metaphor in python.
# metaphor-python

## Installation

Install `metaphor-python` via pip:

```bash
pip install metaphor-python
```

## Usage
Import the package and initialize the Metaphor client with your API key:

```python
from metaphor_python import Metaphor

client = Metaphor(api_key="your-api-key")
```

## Search Request
You can perform a search by creating a SearchRequest object and passing it to the search method:

```python
from metaphor_python import SearchRequest

request = SearchRequest(query="Here is a reaully interesting AI company:", num_results=5)
response = client.search(request)

for result in response.results:
print(result.title, result.url)
```

## Find Similar
To find documents similar to a given URL, you can use the FindSimilarRequest object:

```python
from metaphor_python import FindSimilarRequest

request = FindSimilarRequest(url="https://example.com/article", num_results=5)
response = client.find_similar(request)

for result in response.results:
print(result.title, result.url)
```

## Retrieve Document Contents
To retrieve the contents of documents, use the GetContentsRequest object:

from metaphor_python import GetContentsRequest

```python
request = GetContentsRequest(ids=["doc1", "doc2"])
response = client.get_contents(request)

for content in response.contents:
print(content.title, content.url)
```

# Contribution
Contributions to metaphor-python are very welcome! Feel free to submit pull requests or raise issues.

0 comments on commit 035bf4d

Please sign in to comment.