Skip to content

Commit

Permalink
update README.md; fix a bug of middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
lyricat committed Mar 27, 2023
1 parent 71617ea commit 4ef8d10
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ An AI framework for building cool things.

```bash
curl --location --request POST 'https://botastic-api.pando.im/api/conversations/oneway' \
--header 'X-BOTASTIC-APPID: your botastic app id' \
--header 'X-BOTASTIC-SECRET: your botastic app secret' \
--header 'X-BOTASTIC-APPID: YOUR_BOTASTIC_APP_ID' \
--header 'X-BOTASTIC-SECRET: YOUR_BOTASTIC_APP_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"bot_id": "your bot id",
"bot_id": YOUR_BOT_ID,
"content": "How do you view the future of blockchain, and what benefits does it have for human being? Respond as short as possible like a Zen Master.",
"category": "plain-text"
}'
```

## Documentation

Please refer to [Guide](https://developers.pando.im/guide/botastic.html) and [API Reference](https://developers.pando.im/references/botastic/api.html) for more details.

## Showcases

- [Ask Vitalik](https://ask-vitalik.xingchi.dev): A digital avatar of Vitalik Buterin.
Expand Down
2 changes: 1 addition & 1 deletion cmd/httpd/httpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewCmdHttpd() *cobra.Command {
}, client, users, models)
indexService := indexServ.NewService(ctx, gptHandler, indexes, userz)

middlewarez := middlewareServ.New(middlewareServ.Config{}, indexService)
middlewarez := middlewareServ.New(middlewareServ.Config{}, apps, indexService)
botz := botServ.New(botServ.Config{}, apps, bots, middlewarez)
convz := convServ.New(convServ.Config{}, convs, botz)
orderz := orderServ.New(orderServ.Config{
Expand Down
15 changes: 14 additions & 1 deletion service/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

func New(
cfg Config,
apps core.AppStore,
indexz core.IndexService,
) *service {
middlewareMap := make(map[string]*core.Middleware)
Expand All @@ -25,6 +26,7 @@ func New(
}
return &service{
cfg: cfg,
apps: apps,
indexz: indexz,

middlewareMap: middlewareMap,
Expand All @@ -37,6 +39,7 @@ type (

service struct {
cfg Config
apps core.AppStore
indexz core.IndexService

middlewareMap map[string]*core.Middleware
Expand Down Expand Up @@ -83,12 +86,22 @@ The possible intents should be one of following. If you have no confident about

func (s *service) ProcessBotasticSearch(ctx context.Context, m *core.Middleware, input string) (*core.MiddlewareProcessResult, error) {
limit := 3
app := session.AppFrom(ctx)

val, ok := m.Options["limit"]
if ok {
limit = int(val.(float64))
}

app := session.AppFrom(ctx)
val, ok = m.Options["app_id"]
if ok {
appID := string(val.(string))
givingApp, err := s.apps.GetAppByAppID(ctx, appID)
if err == nil {
app = givingApp
}
}

searchResult, err := s.indexz.SearchIndex(ctx, app.UserID, input, limit)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion store/model/models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
- provider: openai
provider_model: text-embedding-ada-002
price_usd: 0.0000004 # 0.0004 per 1000 tokens
max_token: 2049
max_token: 8191

0 comments on commit 4ef8d10

Please sign in to comment.