아티팩트에 데이터를 전달하는 방법은?

아티팩트에 데이터를 전달하는 방법에 대한 팁이 있을까요? 같은 아티팩트를 포럼의 여러 위치에 붙여넣고 싶고, 각 위치마다 다른 JWT 토큰을 사용하고 싶습니다. 아래와 같은 방법으로 시도해 보았지만 크리에이터가 이를 사용하지 못하게 됩니다:


<div class="ai-artifact" data-jwt-token="my-jwt-token" data-ai-artifact-id="10"></div>

아니면 웹 크리에이터가 현재 어떤 토픽 ID 안에 있는지 파악할 수 있다면, 그것을 활용해서 작업할 수 있을 것 같습니다.

3개의 좋아요

Oh this is a tricky one, no this is not something the framework allows at the moment, it is a very interesting use case.

I like the feature request here of just passing along all data- attributes into the sandboxed artifact, it is an elegant solution.

One option that may work though is to lean on query params, but the sandboxed iframe had no access to that:

https://meta.discourse.org/discourse-ai/ai-bot/artifacts/166?222

@david do you think there is any security implication to passing in information about the outside world to an artifact? (leave sandbox, but I guess echo window.location.search into some sort of attribute?

3개의 좋아요

Giving the artefact access to the query string sounds ok. Easiest thing would be to use Ruby to inject it into the untrusted html document. Maybe as a meta tag or something.

3개의 좋아요

It was the bot’s idea. :slight_smile:

I would think it’s a very common use case for real-world artifacts. I have a financial analysis artifact that I want to run against many investments. The artifact pulls the performance data from an API, using the JWT to identify which investment. Making many different artifacts, each with a different hardcoded JWT, is a non-starter.

Not to push my luck, but if I could also get the user id and topic id in the artifact, that would open up a lot more applications.

4개의 좋아요

topic id is easy to add, but user id can get a tiny bit more tricky, cause the artifact is heavily cached, we would have to reduce some of the caching to make that happen.

That would actually be better for my application than passing data attributes. There’s a 1:1 mapping between topics and my JWTs, so I can look up the JWT, without having to edit the JWT in each post.

That probably doesn’t handle other use cases though.

Technically, just passing the URL solves this, cause the topic id is part of the URL

Will sort this out next week, working on PDF support atm :slight_smile:

확인 차问一下, 이 기능이 실제로 구현된 적이 있나요?

아직은요. 오늘 좀 직접 해보면서 이 정도까지 복잡한지 확인해 볼 거예요.

이것으로 해결됩니다. 샌드박싱 때문에 여기서 post message를 사용해야 하는 것이 불가피합니다. 그래서 API는 await를 필요로 합니다. 그래도 작동하니까 다행입니다.

7개의 좋아요

나한테는 완벽하게 잘 작동해요!

1개의 좋아요