Skip to content

Commit

Permalink
chore: make it simple
Browse files Browse the repository at this point in the history
  • Loading branch information
sykp241095 committed Apr 17, 2024
1 parent f860bb4 commit 69635bc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
15 changes: 13 additions & 2 deletions examples/llamaindex-tidb-vector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ export TIDB_PASSWORD="****"

### Run this example

```bash
python app.py
```text
$ python talk_to_url.py --help
Usage: talk_to_url.py [OPTIONS]
Options:
--url TEXT URL you want to talk to,
default=https://docs.pingcap.com/tidb/stable/overview
--help Show this message and exit.
$
$ python talk_to_url.py
Enter your question: : tidb vs mysql
TiDB is an open-source distributed SQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads. It is MySQL compatible and features horizontal scalability, strong consistency, and high availability. TiDB is designed to provide users with a one-stop database solution that covers OLTP, OLAP, and HTAP services. It offers easy horizontal scaling, financial-grade high availability, real-time HTAP capabilities, cloud-native features, and compatibility with the MySQL protocol and ecosystem.
Enter your question: :
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@
query_engine = tidb_vec_index.as_query_engine(streaming=True)


def do_prepare_data():
documents = SimpleWebPageReader(html_to_text=True).load_data(
["http://paulgraham.com/worked.html"]
)
def do_prepare_data(url):
documents = SimpleWebPageReader(html_to_text=True).load_data([url,])
tidb_vec_index.from_documents(documents, storage_context=storage_context, show_progress=True)


if __name__ == '__main__':
do_prepare_data()
_default_url = 'https://docs.pingcap.com/tidb/stable/overview'

@click.command()
@click.option('--url',default=_default_url,
help=f'URL you want to talk to, default={_default_url}')
def talk_to(url):
do_prepare_data(url)
while True:
question = click.prompt("Enter your question: ")
response = query_engine.query(question)
click.echo(response)

if __name__ == '__main__':
talk_to()

0 comments on commit 69635bc

Please sign in to comment.